mirror of
https://github.com/lWolvesl/antigravity-usage-monitor.git
synced 2026-11-26 17:09:28 +08:00
Merge pull request #9 from yuhuan2498281558/release/v1.4.4
feat(panel): 3-tier update modes, topbar update prompt, and Gemini Hydrogen & Helix support (v1.4.4)
This commit is contained in:
@@ -23,13 +23,13 @@ Antigravity 双栖监控插件(支持主窗口顶栏胶囊悬浮面板与右
|
||||
- 选择面板挂载方式:双栖挂载(顶部栏 + 侧边栏)或仅侧边栏。
|
||||
- 顶部栏定制:独立开关实时运行会话入口,并自由定义右侧三个指标槽位的显示内容与排列顺序。
|
||||
- 选择模型名称格式:精简代号或原始模型 ID。
|
||||
- 版本更新与价格表同步:支持从云端 [`pricing-catalog.json`](pricing-catalog.json) 动态同步最新模型价格表,并支持在面板内一键检查更新或开启后台自动安装新版本。
|
||||
- 版本更新与价格表同步:支持从云端 [`pricing-catalog.json`](pricing-catalog.json) 动态同步最新模型价格表,并提供「仅提示新版本,手动更新」(默认)、「自动更新」与「关闭更新」三档更新方式。
|
||||
|
||||
## 模型识别与费用口径
|
||||
|
||||
模型优先取自当前步骤的原始用量或对应生成记录。自动压缩可能使用独立模型;明确记录的模型不会被覆盖。压缩步骤缺少模型时,会从同一会话中有明确模型的步骤推断:优先查找此前、其次此后的提供方兼容步骤,找不到时再放宽提供方限制。推断结果用于模型展示和费用估算,并不代表服务端已确认压缩模型;没有可用记录时显示“模型未知·压缩”。
|
||||
|
||||
模型或价格未能确认时,单步费用显示“待定”,Token 仍计入统计。汇总费用显示“已知金额 + 待定”,消耗页注明未定价步数。模型明确且价格表已收录的步骤继续按本地 API 单价折算;这不代表订阅额度的美元换算关系。
|
||||
模型或价格未能确认时,单步费用显示“待定”,Token 仍计入统计;汇总费用累加所有已确认单价的步骤。模型明确且价格表已收录的步骤继续按本地 API 单价折算;这不代表订阅额度的美元换算关系。
|
||||
|
||||
升级时会重新读取旧缓存的原始记录。旧版默认填入的 Argon 标签无法与真实 Argon 区分;原始记录暂时无法读取时,该标签会暂记为未知,Token 和已有有效计时保留。压缩步骤可显示完整请求 TPS,但不进入会话均速。
|
||||
|
||||
@@ -75,7 +75,7 @@ Expand-Archive -Path "$env:TEMP\usage-monitor.zip" -DestinationPath $pluginsDir
|
||||
## 更新
|
||||
|
||||
插件内置了云端版本检测与一键更新支持:
|
||||
- 当检测到新版本时,面板顶部栏会显示 **「升级 vX.Y.Z」** 徽章,点击即可自动拉取更新并重启面板;也可在 **偏好设置 -> 版本更新** 中手动更新价格表、检查更新或开启「后台自动安装新版本」。
|
||||
- 当检测到新版本时,顶部栏胶囊旁与面板顶部会显示柔和的新版本提示徽章,点击即可自动拉取更新并重启面板;也可在 **偏好设置 -> 版本更新** 中切换更新方式(仅提示新版本手动更新 / 自动更新 / 关闭更新)或手动同步价格表。
|
||||
|
||||
如需通过命令行手动更新:
|
||||
- 通过 Git 安装时,拉取最新代码后在 **Customizations -> Installed** 中重新开关一次插件即可:
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "usage-monitor",
|
||||
"displayName": "Usage & Speed Monitor",
|
||||
"version": "1.4.3",
|
||||
"version": "1.4.4",
|
||||
"description": "实时查看生成速度、首字延迟、上下文占用、可用额度及历史用量。",
|
||||
"logo": "assets/logo.svg",
|
||||
"suggestedPrompts": [
|
||||
|
||||
+21
-3
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"catalogVersion": "2026.11.11.2",
|
||||
"updatedAt": "2026-11-11T17:25:00+09:00",
|
||||
"latestPluginVersion": "1.4.3",
|
||||
"catalogVersion": "2026.11.11.4",
|
||||
"updatedAt": "2026-11-11T23:20:00+09:00",
|
||||
"latestPluginVersion": "1.4.4",
|
||||
"releaseUrl": "https://github.com/yuhuan2498281558/antigravity-usage-monitor/releases/latest",
|
||||
"downloadUrl": "https://github.com/yuhuan2498281558/antigravity-usage-monitor/releases/latest/download/usage-monitor.zip",
|
||||
"archiveFallbackUrl": "https://codeload.github.com/yuhuan2498281558/antigravity-usage-monitor/zip/refs/heads/main",
|
||||
@@ -15,6 +15,24 @@
|
||||
"gemini-4-argon-medium": { "input": 2.00, "cache": 0.10, "output": 10.0, "short": "argon-4", "family": "Gemini" },
|
||||
"gemini-4-argon-low": { "input": 2.00, "cache": 0.10, "output": 10.0, "short": "argon-4-low", "family": "Gemini" },
|
||||
"gemini-4-argon": { "input": 2.00, "cache": 0.10, "output": 10.0, "short": "argon-4", "family": "Gemini" },
|
||||
"gemini-4-hydrogen-high": { "input": 0.75, "cache": 0.075, "output": 3.75, "short": "hydrogen-4-high", "family": "Gemini" },
|
||||
"gemini-4-hydrogen-medium": { "input": 0.75, "cache": 0.075, "output": 3.75, "short": "hydrogen-4", "family": "Gemini" },
|
||||
"gemini-4-hydrogen-low": { "input": 0.30, "cache": 0.03, "output": 2.50, "short": "hydrogen-4-low", "family": "Gemini" },
|
||||
"gemini-4-hydrogen-tiered": { "input": 0.75, "cache": 0.075, "output": 3.75, "short": "hydrogen-4", "family": "Gemini" },
|
||||
"gemini-4-hydrogen": { "input": 0.75, "cache": 0.075, "output": 3.75, "short": "hydrogen-4", "family": "Gemini" },
|
||||
"gemini-hydrogen-high": { "input": 0.75, "cache": 0.075, "output": 3.75, "short": "hydrogen-high", "family": "Gemini" },
|
||||
"gemini-hydrogen-medium": { "input": 0.75, "cache": 0.075, "output": 3.75, "short": "hydrogen", "family": "Gemini" },
|
||||
"gemini-hydrogen-low": { "input": 0.30, "cache": 0.03, "output": 2.50, "short": "hydrogen-low", "family": "Gemini" },
|
||||
"gemini-hydrogen-tiered": { "input": 0.75, "cache": 0.075, "output": 3.75, "short": "hydrogen", "family": "Gemini" },
|
||||
"gemini-hydrogen": { "input": 0.75, "cache": 0.075, "output": 3.75, "short": "hydrogen", "family": "Gemini" },
|
||||
"gemini-4-helix-high": { "input": 0.30, "cache": 0.03, "output": 2.50, "short": "helix-4-high", "family": "Gemini" },
|
||||
"gemini-4-helix-medium": { "input": 0.30, "cache": 0.03, "output": 2.50, "short": "helix-4", "family": "Gemini" },
|
||||
"gemini-4-helix-low": { "input": 0.30, "cache": 0.03, "output": 2.50, "short": "helix-4-low", "family": "Gemini" },
|
||||
"gemini-4-helix": { "input": 0.30, "cache": 0.03, "output": 2.50, "short": "helix-4", "family": "Gemini" },
|
||||
"gemini-helix-high": { "input": 0.30, "cache": 0.03, "output": 2.50, "short": "helix-high", "family": "Gemini" },
|
||||
"gemini-helix-medium": { "input": 0.30, "cache": 0.03, "output": 2.50, "short": "helix", "family": "Gemini" },
|
||||
"gemini-helix-low": { "input": 0.30, "cache": 0.03, "output": 2.50, "short": "helix-low", "family": "Gemini" },
|
||||
"gemini-helix": { "input": 0.30, "cache": 0.03, "output": 2.50, "short": "helix", "family": "Gemini" },
|
||||
"gemini-3.8-flash-high": { "input": 0.75, "cache": 0.075, "output": 3.75, "short": "flash-3.8-high", "family": "Gemini" },
|
||||
"gemini-3.8-flash-medium": { "input": 0.75, "cache": 0.075, "output": 3.75, "short": "flash-3.8", "family": "Gemini" },
|
||||
"gemini-3.8-flash-low": { "input": 0.30, "cache": 0.03, "output": 2.50, "short": "flash-3.8-low", "family": "Gemini" },
|
||||
|
||||
+241
-62
@@ -82,6 +82,9 @@ const SVG_ICON_DEFS = Object.freeze({
|
||||
'arrow-down': [
|
||||
{ tag: 'path', attrs: { d: 'M8 2.8v10.4M4.2 9.4L8 13.2l3.8-3.8' } },
|
||||
],
|
||||
'arrow-up': [
|
||||
{ tag: 'path', attrs: { d: 'M8 13.2V2.8M4.2 6.6L8 2.8l3.8 3.8' } },
|
||||
],
|
||||
dock: [
|
||||
{ tag: 'rect', attrs: { x: '1.8', y: '2.5', width: '12.4', height: '11', rx: '1.5' } },
|
||||
{ tag: 'path', attrs: { d: 'M1.8 6h12.4' } },
|
||||
@@ -565,15 +568,14 @@ function formatDateSpanBadge(startMs, endMs) {
|
||||
return `${s.getMonth() + 1}月${s.getDate()}日 ~ ${e.getMonth() + 1}月${e.getDate()}日`;
|
||||
}
|
||||
|
||||
function formatUsd(amount, { precise = false, unpricedCalls = 0, compactPending = false } = {}) {
|
||||
function formatUsd(amount, { precise = false } = {}) {
|
||||
if (amount == null || !Number.isFinite(Number(amount))) return '待定';
|
||||
const val = Number(amount || 0);
|
||||
const suffix = unpricedCalls > 0 ? (compactPending ? '+' : ' + 待定') : '';
|
||||
if (precise) {
|
||||
if (val > 0 && val < 0.001) return `<$0.001${suffix}`;
|
||||
return (val >= 1 ? `$${val.toFixed(2)}` : `$${val.toFixed(3)}`) + suffix;
|
||||
if (val > 0 && val < 0.001) return '<$0.001';
|
||||
return val >= 1 ? `$${val.toFixed(2)}` : `$${val.toFixed(3)}`;
|
||||
}
|
||||
return `$${val.toFixed(2)}${suffix}`;
|
||||
return `$${val.toFixed(2)}`;
|
||||
}
|
||||
|
||||
function speedReasonText(reason) {
|
||||
@@ -935,17 +937,32 @@ function normalizeClientTopbarSlots(raw) {
|
||||
return slots;
|
||||
}
|
||||
|
||||
/**
|
||||
* 归一化前端插件更新策略(`'off'` | `'manual'` | `'auto'`),兼容旧版布尔字段。
|
||||
*
|
||||
* @param {unknown} mode
|
||||
* @param {unknown} [legacyAutoUpdate]
|
||||
* @returns {'off'|'manual'|'auto'}
|
||||
*/
|
||||
function normalizeClientUpdateMode(mode, legacyAutoUpdate) {
|
||||
const m = String(mode ?? '').trim().toLowerCase();
|
||||
if (m === 'off' || m === 'manual' || m === 'auto') return m;
|
||||
if (legacyAutoUpdate === true) return 'auto';
|
||||
return 'manual';
|
||||
}
|
||||
|
||||
function isEquivalentTelemetry(prev, next) {
|
||||
if (!prev || !next) return false;
|
||||
if (prev === next) return true;
|
||||
|
||||
// 1. 比对系统设置项(模型显示策略、周预算模式与额度、插件自动更新开关、双栖与顶栏槽位配置)
|
||||
// 1. 比对系统设置项(模型显示策略、周预算模式与额度、插件更新策略、双栖与顶栏槽位配置)
|
||||
const pAct = prev.activeConversation;
|
||||
const nAct = next.activeConversation;
|
||||
if (prev.settings?.showUpstreamModel !== next.settings?.showUpstreamModel) return false;
|
||||
if (prev.settings?.weeklyLimitMode !== next.settings?.weeklyLimitMode) return false;
|
||||
if (prev.settings?.weeklyTokenBudget !== next.settings?.weeklyTokenBudget) return false;
|
||||
if (prev.settings?.weeklyCostBudget !== next.settings?.weeklyCostBudget) return false;
|
||||
if ((prev.settings?.pluginUpdateMode ?? '') !== (next.settings?.pluginUpdateMode ?? '')) return false;
|
||||
if (prev.settings?.autoUpdatePlugin !== next.settings?.autoUpdatePlugin) return false;
|
||||
if (prev.settings?.enableWindowOverlay !== next.settings?.enableWindowOverlay) return false;
|
||||
if ((prev.settings?.showTopbarMultiSession !== false) !== (next.settings?.showTopbarMultiSession !== false)) {
|
||||
@@ -1942,7 +1959,9 @@ const CustomSelect = defineComponent({
|
||||
const matchedOpt = options.find((o) => o.value === modelValue);
|
||||
const selectedOpt = matchedOpt || (!modelValue ? options[0] : undefined);
|
||||
const fallbackText = modelValue ? `${placeholder} (${String(modelValue).slice(0, 8)})` : placeholder;
|
||||
patchText(triggerLabel, selectedOpt ? selectedOpt.label : fallbackText);
|
||||
const labelText = selectedOpt ? selectedOpt.label : fallbackText;
|
||||
patchText(triggerLabel, labelText);
|
||||
patchAttr(triggerBtn, 'title', labelText);
|
||||
if (isOpen) {
|
||||
renderMenuOptions();
|
||||
}
|
||||
@@ -2939,7 +2958,6 @@ function createTrendAreaChart() {
|
||||
patchText(
|
||||
tipCostEl,
|
||||
formatUsd(slotCost, {
|
||||
unpricedCalls: slot.unpricedCalls,
|
||||
precise: slotCost > 0 && slotCost < 0.1,
|
||||
})
|
||||
);
|
||||
@@ -3291,9 +3309,13 @@ const TopSessionHeader = defineComponent({
|
||||
const aggregated = actConv?.aggregated;
|
||||
|
||||
const cloudStatus = telemetry?.cloudStatus;
|
||||
const hasUpdate = Boolean(cloudStatus?.updateAvailable);
|
||||
patchAttr(updateBtn, 'hidden', !hasUpdate);
|
||||
if (hasUpdate && !isHeaderUpdating) {
|
||||
const updateMode = normalizeClientUpdateMode(
|
||||
telemetry?.settings?.pluginUpdateMode,
|
||||
telemetry?.settings?.autoUpdatePlugin
|
||||
);
|
||||
const showUpdate = Boolean(cloudStatus?.updateAvailable) && updateMode !== 'off';
|
||||
patchAttr(updateBtn, 'hidden', !showUpdate);
|
||||
if (showUpdate && !isHeaderUpdating) {
|
||||
patchText(
|
||||
updateBtnText,
|
||||
cloudStatus?.latestPluginVersion
|
||||
@@ -4251,7 +4273,7 @@ const LiveOverviewView = defineComponent({
|
||||
);
|
||||
patchText(
|
||||
cacheSub,
|
||||
`缓存 ${active.latestCacheHitPct ?? 0}% · 累计 ${formatUsd(active.sessionCostUsd || 0, { unpricedCalls: active.sessionUnpricedCalls })}`
|
||||
`缓存 ${active.latestCacheHitPct ?? 0}% · 累计 ${formatUsd(active.sessionCostUsd || 0)}`
|
||||
);
|
||||
|
||||
// 2. 更新 10 段上下文窗口构成与内嵌上下文窗口检视胶囊条
|
||||
@@ -4413,7 +4435,7 @@ const LiveOverviewView = defineComponent({
|
||||
|
||||
patchText(
|
||||
wkFootLeft,
|
||||
`本周累计: ${formatTokens(weekly.tokens || 0)} (${formatUsd(weekly.costUsd || 0, { unpricedCalls: weekly.unpricedCalls })})`
|
||||
`本周累计: ${formatTokens(weekly.tokens || 0)} (${formatUsd(weekly.costUsd || 0)})`
|
||||
);
|
||||
patchText(
|
||||
wkFootRight,
|
||||
@@ -4906,7 +4928,7 @@ const ConsumptionView = defineComponent({
|
||||
patchText(refs.pctBadge, `${share.toFixed(1)}%`);
|
||||
patchText(refs.totalTokEl, showTokensInHeader ? formatTokensPrecise(total) : '');
|
||||
patchAttr(refs.totalTokEl, 'hidden', !showTokensInHeader);
|
||||
patchText(refs.costEl, formatUsd(item.costUsd || 0, { unpricedCalls: item.unpricedCalls }));
|
||||
patchText(refs.costEl, formatUsd(item.costUsd || 0));
|
||||
|
||||
const responseTok =
|
||||
item.responseTokens != null
|
||||
@@ -4966,8 +4988,8 @@ const ConsumptionView = defineComponent({
|
||||
|
||||
patchText(heroTotalTokens, formatTokensPrecise(totalTokens));
|
||||
patchText(heroTotalCalls, `${acct.calls || 0} 次`);
|
||||
patchText(heroCostUsd, formatUsd(costUsd, { unpricedCalls: acct.unpricedCalls }));
|
||||
patchText(heroCostCny, acct.unpricedCalls > 0 ? `${acct.unpricedCalls} 步费用待定` : formatCnyApprox(costUsd));
|
||||
patchText(heroCostUsd, formatUsd(costUsd));
|
||||
patchText(heroCostCny, formatCnyApprox(costUsd));
|
||||
|
||||
patchText(cacheHitPctEl, `${Number(acct.cacheHitPct ?? 0).toFixed(1)}%`);
|
||||
patchText(cacheTokensEl, `命中 ${formatTokensPrecise(cacheTokens)}`);
|
||||
@@ -5091,11 +5113,7 @@ const ConsumptionView = defineComponent({
|
||||
const cVal = Number(m.costUsd || 0);
|
||||
patchText(
|
||||
col.costText,
|
||||
m.unpricedCalls > 0
|
||||
? formatUsd(cVal, { unpricedCalls: m.unpricedCalls, compactPending: true })
|
||||
: cVal >= 10
|
||||
? `$${Math.round(cVal)}`
|
||||
: `$${cVal.toFixed(2)}`
|
||||
cVal >= 10 ? `$${Math.round(cVal)}` : `$${cVal.toFixed(2)}`
|
||||
);
|
||||
patchText(col.tokText, formatTokensPrecise(mTot));
|
||||
|
||||
@@ -5261,8 +5279,8 @@ const StepsDetailView = defineComponent({
|
||||
style: 'flex: 1; min-height: 0; display: flex; flex-direction: column;',
|
||||
},
|
||||
[
|
||||
h('div', { className: 'panel-header' }, [
|
||||
h('span', { className: 'panel-title' }, [
|
||||
h('div', { className: 'panel-header steps-panel-header' }, [
|
||||
h('span', { className: 'panel-title steps-panel-title' }, [
|
||||
createSvgIcon('table', { size: 13 }),
|
||||
h('span', { text: '调用记录' }),
|
||||
]),
|
||||
@@ -5491,7 +5509,7 @@ const StepsDetailView = defineComponent({
|
||||
patchText(refs.speedMain, formatMetric(m.avgTokPerSec, ' tok/s'));
|
||||
patchText(refs.speedSub, `有效 ${sampleSummary(m.speedSummary)}`);
|
||||
patchText(refs.tdTokens, formatTokens(m.totalTokens || 0));
|
||||
patchText(refs.tdCost, formatUsd(m.costUsd, { unpricedCalls: m.unpricedCalls }));
|
||||
patchText(refs.tdCost, formatUsd(m.costUsd || 0));
|
||||
},
|
||||
});
|
||||
|
||||
@@ -5609,10 +5627,11 @@ const TOPBAR_SLOT_OPTIONS = [
|
||||
{ value: 'none', label: '不显示' },
|
||||
];
|
||||
|
||||
/** 插件版本更新策略可选项 */
|
||||
/** 插件版本更新策略可选项(默认仅提示新版本、手动更新) */
|
||||
const AUTO_UPDATE_OPTIONS = [
|
||||
{ value: 'manual', label: '仅提示新版本,手动更新 (推荐)' },
|
||||
{ value: 'auto', label: '后台自动安装新版本' },
|
||||
{ value: 'manual', label: '仅提示新版本,手动更新' },
|
||||
{ value: 'auto', label: '自动更新' },
|
||||
{ value: 'off', label: '关闭更新' },
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -5634,7 +5653,7 @@ const SettingsView = defineComponent({
|
||||
name: 'SettingsView',
|
||||
setup({ onCleanup }) {
|
||||
let draftShowUpstreamModel = false;
|
||||
let draftAutoUpdatePlugin = false;
|
||||
let draftPluginUpdateMode = 'manual';
|
||||
let draftEnableWindowOverlay = true;
|
||||
let draftShowTopbarMulti = true;
|
||||
let draftTopbarSlots = [...DEFAULT_CLIENT_TOPBAR_SLOTS];
|
||||
@@ -5930,19 +5949,26 @@ const SettingsView = defineComponent({
|
||||
icon: 'refresh',
|
||||
options: AUTO_UPDATE_OPTIONS,
|
||||
onUpdateModelValue: async (val) => {
|
||||
const nextAuto = val === 'auto';
|
||||
draftAutoUpdatePlugin = nextAuto;
|
||||
autoUpdateSelect.setValue(nextAuto ? 'auto' : 'manual');
|
||||
const nextMode = normalizeClientUpdateMode(val);
|
||||
draftPluginUpdateMode = nextMode;
|
||||
autoUpdateSelect.setValue(nextMode);
|
||||
if (latestCloudStatus) {
|
||||
renderCloudStatus(latestCloudStatus);
|
||||
}
|
||||
showCloudFeedback('保存中…', 0);
|
||||
try {
|
||||
await saveSettingsPatch({
|
||||
autoUpdatePlugin: nextAuto,
|
||||
pluginUpdateMode: nextMode,
|
||||
autoUpdatePlugin: nextMode === 'auto',
|
||||
});
|
||||
showCloudFeedback('已保存', 1800);
|
||||
} catch {
|
||||
if (latestSettings) {
|
||||
renderSettings(latestSettings);
|
||||
}
|
||||
if (latestCloudStatus) {
|
||||
renderCloudStatus(latestCloudStatus);
|
||||
}
|
||||
showCloudFeedback('保存失败', 2500);
|
||||
}
|
||||
},
|
||||
@@ -5950,7 +5976,7 @@ const SettingsView = defineComponent({
|
||||
|
||||
const pricingCountVal = h('strong', { className: 'cell-value', text: '—' });
|
||||
const pricingSyncSub = h('span', { className: 'cell-sub', text: '读取中…' });
|
||||
const versionVal = h('strong', { className: 'cell-value', text: 'v1.4.3' });
|
||||
const versionVal = h('strong', { className: 'cell-value', text: 'v1.4.4' });
|
||||
const versionSub = h('span', { className: 'cell-sub', text: '检查中…' });
|
||||
|
||||
const syncPricingBtnText = h('span', { text: '更新价格表' });
|
||||
@@ -6005,7 +6031,7 @@ const SettingsView = defineComponent({
|
||||
return;
|
||||
}
|
||||
if (!cs?.updateAvailable) {
|
||||
const curVer = cs?.currentPluginVersion || '1.4.3';
|
||||
const curVer = cs?.currentPluginVersion || '1.4.4';
|
||||
showCloudFeedback(`当前已是最新版本 (v${curVer})`, 4500);
|
||||
return;
|
||||
}
|
||||
@@ -6041,7 +6067,7 @@ const SettingsView = defineComponent({
|
||||
cloudStatusMsg,
|
||||
]),
|
||||
h('div', { className: 'form-row' }, [
|
||||
h('span', { className: 'form-label', text: '自动更新' }),
|
||||
h('span', { className: 'form-label', text: '更新方式' }),
|
||||
autoUpdateSelect.el,
|
||||
]),
|
||||
h('div', { className: 'dual-grid' }, [
|
||||
@@ -6078,14 +6104,17 @@ const SettingsView = defineComponent({
|
||||
function renderSettings(settings) {
|
||||
if (!settings) return;
|
||||
draftShowUpstreamModel = Boolean(settings.showUpstreamModel);
|
||||
draftAutoUpdatePlugin = Boolean(settings.autoUpdatePlugin);
|
||||
draftPluginUpdateMode = normalizeClientUpdateMode(
|
||||
settings.pluginUpdateMode,
|
||||
settings.autoUpdatePlugin
|
||||
);
|
||||
draftEnableWindowOverlay = settings.enableWindowOverlay !== false;
|
||||
draftShowTopbarMulti = settings.showTopbarMultiSession !== false;
|
||||
draftTopbarSlots = normalizeClientTopbarSlots(settings.topbarCapsuleSlots);
|
||||
|
||||
windowMountSelect.setValue(draftEnableWindowOverlay ? 'dual' : 'sidebar');
|
||||
stepModelSelect.setValue(draftShowUpstreamModel ? 'upstream' : 'short');
|
||||
autoUpdateSelect.setValue(draftAutoUpdatePlugin ? 'auto' : 'manual');
|
||||
autoUpdateSelect.setValue(draftPluginUpdateMode);
|
||||
syncTopbarControls();
|
||||
viewScrollbar.refresh();
|
||||
}
|
||||
@@ -6105,15 +6134,20 @@ const SettingsView = defineComponent({
|
||||
`${srcLabel} · ${formatSyncTimeText(cs.lastSyncedAtMs, cs.catalogUpdatedAt)}`
|
||||
);
|
||||
|
||||
const curVer = cs.currentPluginVersion || '1.4.3';
|
||||
const curVer = cs.currentPluginVersion || '1.4.4';
|
||||
const latVer = cs.latestPluginVersion || curVer;
|
||||
const modeTag = cs.installMode === 'git' ? 'Git' : 'ZIP';
|
||||
patchText(versionVal, `v${curVer}`);
|
||||
if (cs.updateAvailable) {
|
||||
if (cs.updateAvailable && draftPluginUpdateMode !== 'off') {
|
||||
patchText(versionSub, `可升级至 v${latVer} (${modeTag})`);
|
||||
patchClasses(versionSub, { 'accent-ok': true });
|
||||
patchText(updatePluginBtnText, `升级至 v${latVer}`);
|
||||
patchClasses(updatePluginBtn, { 'btn-primary': true, 'btn-secondary': false });
|
||||
} else if (draftPluginUpdateMode === 'off') {
|
||||
patchText(versionSub, `已关闭更新提醒 (${modeTag})`);
|
||||
patchClasses(versionSub, { 'accent-ok': false });
|
||||
patchText(updatePluginBtnText, cs.updateAvailable ? `手动升级 v${latVer}` : '检查更新');
|
||||
patchClasses(updatePluginBtn, { 'btn-primary': false, 'btn-secondary': true });
|
||||
} else {
|
||||
patchText(versionSub, `已是最新 (${modeTag})`);
|
||||
patchClasses(versionSub, { 'accent-ok': false });
|
||||
@@ -6336,28 +6370,30 @@ const RING_CIRCUMFERENCE = +(2 * Math.PI * RING_RADIUS).toFixed(2);
|
||||
function computeCapsuleLayoutMode(availWidth, currentMode = 'wide', options = undefined) {
|
||||
if (availWidth == null || Number.isNaN(availWidth)) return 'wide';
|
||||
const showMulti = options?.showMulti !== false;
|
||||
const effWidth = showMulti ? availWidth : availWidth + 76;
|
||||
const updateReserve = options?.hasUpdate ? 52 : 0;
|
||||
const baseEffWidth = showMulti ? availWidth : availWidth + 76;
|
||||
const effWidth = baseEffWidth - updateReserve;
|
||||
if (currentMode === 'wide') {
|
||||
if (effWidth < 78) return 'ring-only';
|
||||
if (baseEffWidth < 78) return 'ring-only';
|
||||
if (effWidth < 196) return 'minimal';
|
||||
if (effWidth < 256) return 'compact';
|
||||
return 'wide';
|
||||
}
|
||||
if (currentMode === 'compact') {
|
||||
if (effWidth >= 272) return 'wide';
|
||||
if (effWidth < 78) return 'ring-only';
|
||||
if (baseEffWidth < 78) return 'ring-only';
|
||||
if (effWidth < 196) return 'minimal';
|
||||
return 'compact';
|
||||
}
|
||||
if (currentMode === 'minimal') {
|
||||
if (effWidth >= 272) return 'wide';
|
||||
if (effWidth >= 212) return 'compact';
|
||||
if (effWidth < 78) return 'ring-only';
|
||||
if (baseEffWidth < 78) return 'ring-only';
|
||||
return 'minimal';
|
||||
}
|
||||
if (effWidth >= 272) return 'wide';
|
||||
if (effWidth >= 212) return 'compact';
|
||||
if (effWidth >= 92) return 'minimal';
|
||||
if (baseEffWidth >= 92) return 'minimal';
|
||||
return 'ring-only';
|
||||
}
|
||||
|
||||
@@ -6641,9 +6677,16 @@ function mountWindowOverlay() {
|
||||
}
|
||||
const r = capsuleBtn.getBoundingClientRect();
|
||||
if (r.width <= 0 || r.height <= 0) return false;
|
||||
let rightBound = r.right;
|
||||
if (!topbarUpdateBtn.hasAttribute('hidden') && topbarUpdateBtn.getBoundingClientRect) {
|
||||
const ur = topbarUpdateBtn.getBoundingClientRect();
|
||||
if (ur.width > 0 && ur.height > 0) {
|
||||
rightBound = Math.max(rightBound, ur.right);
|
||||
}
|
||||
}
|
||||
return (
|
||||
lastPointerX >= r.left - 1 &&
|
||||
lastPointerX <= r.right + 1 &&
|
||||
lastPointerX <= rightBound + 1 &&
|
||||
lastPointerY >= r.top - 1 &&
|
||||
lastPointerY <= r.bottom + 1
|
||||
);
|
||||
@@ -6875,8 +6918,87 @@ function mountWindowOverlay() {
|
||||
const sep0 = h('span', { className: 'wm-sep wm-sep-speed', 'data-sep-for-rank': '2' });
|
||||
const sep1 = h('span', { className: 'wm-sep wm-sep-quota', 'data-sep-for-rank': '3' });
|
||||
let lastShowMulti = true;
|
||||
let lastShowUpdate = false;
|
||||
let isTopbarUpdating = false;
|
||||
|
||||
const updateDot = h('span', { className: 'wm-update-dot', hidden: true });
|
||||
const topbarUpdateIcon = createSvgIcon('arrow-down', { size: 10 });
|
||||
const topbarUpdateLabel = h('span', { className: 'wm-update-label', text: '新版本' });
|
||||
const topbarUpdateBtn = h(
|
||||
'button',
|
||||
{
|
||||
type: 'button',
|
||||
className: 'wm-update-btn',
|
||||
hidden: true,
|
||||
'aria-label': '发现新版本,点击更新',
|
||||
title: '发现新版本,点击立即更新',
|
||||
onClick: async (e) => {
|
||||
e.stopPropagation();
|
||||
if (isTopbarUpdating) return;
|
||||
isTopbarUpdating = true;
|
||||
patchClasses(topbarUpdateBtn, { 'is-updating': true });
|
||||
patchSvgIcon(topbarUpdateIcon, 'refresh');
|
||||
patchText(topbarUpdateLabel, '更新中…');
|
||||
patchAttr(topbarUpdateBtn, 'disabled', true);
|
||||
try {
|
||||
const res = await triggerPluginUpdate();
|
||||
if (!res?.ok) {
|
||||
uiStore.setState({ activeView: 'settings' });
|
||||
setPopoverOpen(true);
|
||||
}
|
||||
} catch {
|
||||
uiStore.setState({ activeView: 'settings' });
|
||||
setPopoverOpen(true);
|
||||
} finally {
|
||||
isTopbarUpdating = false;
|
||||
patchClasses(topbarUpdateBtn, { 'is-updating': false });
|
||||
patchSvgIcon(topbarUpdateIcon, 'arrow-down');
|
||||
patchAttr(topbarUpdateBtn, 'disabled', false);
|
||||
const cs = telemetryStore.getState().telemetry?.cloudStatus;
|
||||
patchText(
|
||||
topbarUpdateLabel,
|
||||
cs?.latestPluginVersion ? `v${cs.latestPluginVersion}` : '新版本'
|
||||
);
|
||||
}
|
||||
},
|
||||
onMouseenter: (e) => {
|
||||
recordPointerCoords(e);
|
||||
if (hoverLeaveTimer) {
|
||||
clearTimeout(hoverLeaveTimer);
|
||||
hoverLeaveTimer = null;
|
||||
}
|
||||
if (!popoverOpen && !multiPinned) {
|
||||
if (multiOpen) {
|
||||
setMultiOpen(false);
|
||||
}
|
||||
setTooltipOpen(true);
|
||||
}
|
||||
},
|
||||
onMouseleave: (e) => {
|
||||
recordPointerCoords(e);
|
||||
if (hoverLeaveTimer) {
|
||||
clearTimeout(hoverLeaveTimer);
|
||||
}
|
||||
hoverLeaveTimer = setTimeout(() => {
|
||||
hoverLeaveTimer = null;
|
||||
if (disposed || popoverOpen) return;
|
||||
let nativeHover = false;
|
||||
try {
|
||||
nativeHover = Boolean(
|
||||
capsuleBtn.matches?.(':hover') || topbarUpdateBtn.matches?.(':hover')
|
||||
);
|
||||
} catch {
|
||||
nativeHover = false;
|
||||
}
|
||||
if (nativeHover || isPointerStillInCapsule()) {
|
||||
return;
|
||||
}
|
||||
setTooltipOpen(false);
|
||||
}, 40);
|
||||
},
|
||||
},
|
||||
[topbarUpdateIcon, topbarUpdateLabel]
|
||||
);
|
||||
|
||||
const capsuleBtn = h(
|
||||
'button',
|
||||
@@ -6917,7 +7039,9 @@ function mountWindowOverlay() {
|
||||
if (disposed || popoverOpen) return;
|
||||
let nativeHover = false;
|
||||
try {
|
||||
nativeHover = Boolean(capsuleBtn.matches?.(':hover'));
|
||||
nativeHover = Boolean(
|
||||
capsuleBtn.matches?.(':hover') || topbarUpdateBtn.matches?.(':hover')
|
||||
);
|
||||
} catch {
|
||||
nativeHover = false;
|
||||
}
|
||||
@@ -6932,6 +7056,7 @@ function mountWindowOverlay() {
|
||||
);
|
||||
capsuleShadow.appendChild(multiBtn);
|
||||
capsuleShadow.appendChild(capsuleBtn);
|
||||
capsuleShadow.appendChild(topbarUpdateBtn);
|
||||
|
||||
// --- 2. 创建 Body 顶层浮层 Portal Shadow Host ---
|
||||
const portalHost = document.createElement('div');
|
||||
@@ -7058,13 +7183,33 @@ function mountWindowOverlay() {
|
||||
]),
|
||||
]);
|
||||
|
||||
const hoverUpdateVerText = h('span', { text: '发现新版本' });
|
||||
const hoverUpdateHintText = h('span', {
|
||||
className: 'wm-hover-update-hint',
|
||||
text: '点击顶栏版本胶囊即可一键更新',
|
||||
});
|
||||
const hoverUpdateBar = h(
|
||||
'div',
|
||||
{
|
||||
className: 'wm-hover-update-bar',
|
||||
hidden: true,
|
||||
},
|
||||
[
|
||||
h('span', { className: 'wm-hover-update-left' }, [
|
||||
createSvgIcon('arrow-down', { size: 11 }),
|
||||
hoverUpdateVerText,
|
||||
]),
|
||||
hoverUpdateHintText,
|
||||
]
|
||||
);
|
||||
|
||||
const hoverTipEl = h(
|
||||
'div',
|
||||
{
|
||||
className: 'wm-hover-tip',
|
||||
hidden: true,
|
||||
},
|
||||
[hoverMatrixEl, hoverCtxPanel, hoverQuotaPanel]
|
||||
[hoverUpdateBar, hoverMatrixEl, hoverCtxPanel, hoverQuotaPanel]
|
||||
);
|
||||
|
||||
// 左侧多会话实时看板浮层(活跃运行会话卡片 + 近期多窗口会话速览,全槽位预占、就地补丁更新)
|
||||
@@ -7165,16 +7310,11 @@ function mountWindowOverlay() {
|
||||
|
||||
const multiPinBadge = h('span', { className: 'wm-pin-badge', hidden: true, text: '已固定' });
|
||||
const multiRunningMetaEl = h('span', { className: 'panel-meta text-mono', text: '读取中...' });
|
||||
const multiEmptyHintEl = h('span', {
|
||||
className: 'wm-multi-empty-hint',
|
||||
text: '悬停速览 · 左键固定',
|
||||
});
|
||||
const multiEmptyEl = h('div', { className: 'wm-multi-empty' }, [
|
||||
h('span', { className: 'wm-multi-empty-left' }, [
|
||||
h('span', { className: 'wm-idle-dot' }),
|
||||
h('span', { text: '当前暂无在线运行的会话' }),
|
||||
]),
|
||||
multiEmptyHintEl,
|
||||
]);
|
||||
const multiRunningListEl = h('div', {
|
||||
className: 'live-activity-list',
|
||||
@@ -7348,6 +7488,11 @@ function mountWindowOverlay() {
|
||||
multiPanelEl.style.maxHeight = `${Math.max(240, vh - top - 12)}px`;
|
||||
}
|
||||
|
||||
const rightAnchorEdge =
|
||||
!topbarUpdateBtn.hasAttribute('hidden') && topbarUpdateBtn.getBoundingClientRect
|
||||
? Math.max(bRect.right, topbarUpdateBtn.getBoundingClientRect().right || 0)
|
||||
: bRect.right;
|
||||
|
||||
if (popoverOpen) {
|
||||
const rawW =
|
||||
Number(popoverEl.offsetWidth) ||
|
||||
@@ -7355,7 +7500,7 @@ function mountWindowOverlay() {
|
||||
defaultCardW;
|
||||
const panelW = Math.min(rawW, Math.max(280, vw - minLeft - 12));
|
||||
const top = Math.max(38, Math.min(vh - 140, Math.round(bRect.bottom + 6)));
|
||||
let left = Math.round(bRect.right - panelW);
|
||||
let left = Math.round(rightAnchorEdge - panelW);
|
||||
left = Math.min(left, vw - panelW - 12);
|
||||
left = Math.max(minLeft, left);
|
||||
popoverEl.style.top = `${top}px`;
|
||||
@@ -7377,7 +7522,7 @@ function mountWindowOverlay() {
|
||||
if (top + tipH > vh - 8 && bRect.top > tipH + 12) {
|
||||
top = Math.round(bRect.top - tipH - 6);
|
||||
}
|
||||
let left = Math.round(bRect.right - tipW);
|
||||
let left = Math.round(rightAnchorEdge - tipW);
|
||||
left = Math.min(left, vw - tipW - 12);
|
||||
left = Math.max(minLeft, left);
|
||||
hoverTipEl.style.top = `${top}px`;
|
||||
@@ -7393,9 +7538,14 @@ function mountWindowOverlay() {
|
||||
if (disposed) return;
|
||||
const titlebar = findHostTitlebar();
|
||||
const avail = measureAvailableTitlebarWidth(titlebar);
|
||||
const showMulti =
|
||||
telemetryStore.getState().telemetry?.settings?.showTopbarMultiSession !== false;
|
||||
const nextMode = computeCapsuleLayoutMode(avail, layoutMode, { showMulti });
|
||||
const curTel = telemetryStore.getState().telemetry;
|
||||
const showMulti = curTel?.settings?.showTopbarMultiSession !== false;
|
||||
const curUpdateMode = normalizeClientUpdateMode(
|
||||
curTel?.settings?.pluginUpdateMode,
|
||||
curTel?.settings?.autoUpdatePlugin
|
||||
);
|
||||
const hasUpdate = Boolean(curTel?.cloudStatus?.updateAvailable) && curUpdateMode !== 'off';
|
||||
const nextMode = computeCapsuleLayoutMode(avail, layoutMode, { showMulti, hasUpdate });
|
||||
if (nextMode !== layoutMode) {
|
||||
layoutMode = nextMode;
|
||||
capsuleHost.setAttribute('data-layout', layoutMode);
|
||||
@@ -7877,7 +8027,6 @@ function mountWindowOverlay() {
|
||||
: `${runningCount} 个会话运行中`
|
||||
: '全部待命'
|
||||
);
|
||||
patchText(multiEmptyHintEl, '悬停速览 · 左键可固定');
|
||||
patchAttr(multiEmptyEl, 'hidden', runningCount > 0);
|
||||
patchAttr(multiRunningListEl, 'hidden', runningCount === 0);
|
||||
|
||||
@@ -8108,8 +8257,38 @@ function mountWindowOverlay() {
|
||||
quotas: telemetry.quotas,
|
||||
});
|
||||
|
||||
const hasUpdate = Boolean(telemetry.cloudStatus?.updateAvailable);
|
||||
patchAttr(updateDot, 'hidden', !hasUpdate);
|
||||
const updateMode = normalizeClientUpdateMode(
|
||||
telemetry.settings?.pluginUpdateMode,
|
||||
telemetry.settings?.autoUpdatePlugin
|
||||
);
|
||||
const showUpdatePrompt =
|
||||
Boolean(telemetry.cloudStatus?.updateAvailable) && updateMode !== 'off';
|
||||
const latestVer = telemetry.cloudStatus?.latestPluginVersion || '';
|
||||
patchAttr(updateDot, 'hidden', !showUpdatePrompt);
|
||||
patchAttr(topbarUpdateBtn, 'hidden', !showUpdatePrompt);
|
||||
patchAttr(hoverUpdateBar, 'hidden', !showUpdatePrompt);
|
||||
if (showUpdatePrompt) {
|
||||
if (!isTopbarUpdating) {
|
||||
patchText(topbarUpdateLabel, latestVer ? `v${latestVer}` : '新版本');
|
||||
}
|
||||
patchAttr(
|
||||
topbarUpdateBtn,
|
||||
'title',
|
||||
latestVer ? `发现新版本 v${latestVer},左键立即更新` : '发现新版本,左键立即更新'
|
||||
);
|
||||
patchText(
|
||||
hoverUpdateVerText,
|
||||
latestVer ? `发现新版本 v${latestVer}` : '发现新版本可用'
|
||||
);
|
||||
patchText(
|
||||
hoverUpdateHintText,
|
||||
latestVer ? `点击顶栏 v${latestVer} 即可更新` : '点击顶栏版本胶囊即可更新'
|
||||
);
|
||||
}
|
||||
if (showUpdatePrompt !== lastShowUpdate) {
|
||||
lastShowUpdate = showUpdatePrompt;
|
||||
updateResponsiveLayout();
|
||||
}
|
||||
|
||||
// --- 同步悬停三卡片全景概览(与 LiveOverviewView 保持完全一致的数据口径与视觉呈现) ---
|
||||
const showUpstream = Boolean(telemetry.settings?.showUpstreamModel);
|
||||
@@ -8141,7 +8320,7 @@ function mountWindowOverlay() {
|
||||
);
|
||||
patchText(
|
||||
hoverCacheSub,
|
||||
`缓存 ${overviewActive.latestCacheHitPct ?? 0}% · 累计 ${formatUsd(overviewActive.sessionCostUsd || 0, { unpricedCalls: overviewActive.sessionUnpricedCalls })}`
|
||||
`缓存 ${overviewActive.latestCacheHitPct ?? 0}% · 累计 ${formatUsd(overviewActive.sessionCostUsd || 0)}`
|
||||
);
|
||||
|
||||
patchAttr(hoverCtxAgentBadge, 'hidden', !(hasSubagents && ctxAgent));
|
||||
@@ -8186,7 +8365,7 @@ function mountWindowOverlay() {
|
||||
});
|
||||
patchText(
|
||||
hoverWkFootLeft,
|
||||
`本周累计: ${formatTokens(weekly.tokens || 0)} (${formatUsd(weekly.costUsd || 0, { unpricedCalls: weekly.unpricedCalls })})`
|
||||
`本周累计: ${formatTokens(weekly.tokens || 0)} (${formatUsd(weekly.costUsd || 0)})`
|
||||
);
|
||||
patchText(
|
||||
hoverWkFootRight,
|
||||
|
||||
@@ -89,6 +89,22 @@ export const TOPBAR_SLOT_KEYS = Object.freeze([
|
||||
|
||||
export const DEFAULT_TOPBAR_SLOTS = Object.freeze(['context', 'tps', 'quota_auto']);
|
||||
|
||||
export const PLUGIN_UPDATE_MODES = Object.freeze(['off', 'manual', 'auto']);
|
||||
|
||||
/**
|
||||
* 归一化插件更新策略枚举(兼容历史 `autoUpdatePlugin` 布尔开关,默认 `'manual'`)。
|
||||
*
|
||||
* @param {unknown} mode
|
||||
* @param {unknown} [legacyAutoUpdate]
|
||||
* @returns {'off'|'manual'|'auto'}
|
||||
*/
|
||||
export function normalizePluginUpdateMode(mode, legacyAutoUpdate) {
|
||||
const m = String(mode ?? '').trim().toLowerCase();
|
||||
if (m === 'off' || m === 'manual' || m === 'auto') return m;
|
||||
if (legacyAutoUpdate === true) return 'auto';
|
||||
return 'manual';
|
||||
}
|
||||
|
||||
/**
|
||||
* 归一化顶栏三槽位配置数组,兜底非法枚举值并保证至少保留一个可见槽位。
|
||||
*
|
||||
@@ -115,7 +131,8 @@ const DEFAULT_SETTINGS = {
|
||||
weeklyCostBudget: 100, // 自定义每周美元费用预算默认值 ($100,保留底层兼容)
|
||||
weeklyLimitMode: 'official', // 'official' | 'custom_tokens' | 'custom_cost'
|
||||
showUpstreamModel: false, // 是否显示上游真实 responseModel 名称
|
||||
autoUpdatePlugin: false, // 发现新版本且本地工作区干净时是否在后台自动更新插件
|
||||
pluginUpdateMode: 'manual', // 'off' | 'manual' | 'auto'(默认仅提示新版本,手动更新)
|
||||
autoUpdatePlugin: false, // 派生自 pluginUpdateMode === 'auto',保留底层兼容
|
||||
enableWindowOverlay: true, // 是否启用双栖模式(自动通过 CDP 在主窗口顶栏挂载胶囊与悬浮面板)
|
||||
showTopbarMultiSession: true, // 是否在顶栏左侧显示实时运行会话入口
|
||||
topbarCapsuleSlots: [...DEFAULT_TOPBAR_SLOTS], // 顶栏右侧胶囊三槽位指标与顺序
|
||||
@@ -197,6 +214,10 @@ export function loadSettings() {
|
||||
const raw = loadJson(SETTINGS_FILE, {});
|
||||
const safeRaw = isPlainObject(raw) ? raw : {};
|
||||
const merged = { ...DEFAULT_SETTINGS, ...safeRaw };
|
||||
const pluginUpdateMode = normalizePluginUpdateMode(
|
||||
safeRaw.pluginUpdateMode,
|
||||
safeRaw.autoUpdatePlugin
|
||||
);
|
||||
return {
|
||||
weeklyTokenBudget: sanitizeSettingNumber(
|
||||
safeRaw.weeklyTokenBudget ?? safeRaw.weeklyTokenLimit ?? merged.weeklyTokenBudget,
|
||||
@@ -208,7 +229,8 @@ export function loadSettings() {
|
||||
),
|
||||
weeklyLimitMode: normalizeWeeklyLimitMode(merged.weeklyLimitMode),
|
||||
showUpstreamModel: merged.showUpstreamModel === true,
|
||||
autoUpdatePlugin: merged.autoUpdatePlugin === true,
|
||||
pluginUpdateMode,
|
||||
autoUpdatePlugin: pluginUpdateMode === 'auto',
|
||||
enableWindowOverlay: merged.enableWindowOverlay !== false,
|
||||
showTopbarMultiSession: merged.showTopbarMultiSession !== false,
|
||||
topbarCapsuleSlots: normalizeTopbarCapsuleSlots(safeRaw.topbarCapsuleSlots),
|
||||
|
||||
@@ -48,6 +48,8 @@ function inferFamilyFromProviderOrKey(rawModelKey = '', modelId = '', apiProvide
|
||||
combined.includes('GEMINI') ||
|
||||
combined.includes('CARBON') ||
|
||||
combined.includes('ARGON') ||
|
||||
combined.includes('HYDROGEN') ||
|
||||
combined.includes('HELIX') ||
|
||||
combined.includes('FLASH') ||
|
||||
combined.includes('GOOGLE')
|
||||
) {
|
||||
@@ -104,13 +106,21 @@ export function formatGenericModelSlug(slug = '') {
|
||||
.trim()
|
||||
.replace(/^session-display:/i, '');
|
||||
if (!s || /^MODEL_PLACEHOLDER_/i.test(s)) return '';
|
||||
const m = s.match(/^gemini-(\d+(?:\.\d+)?)-(pro|flash|argon|carbon)(?:-(lite))?$/i);
|
||||
const m = s.match(
|
||||
/^gemini-(\d+(?:\.\d+)?)-(pro|flash|argon|carbon|hydrogen|helix)(?:-(lite))?$/i
|
||||
);
|
||||
if (m) {
|
||||
const ver = m[1];
|
||||
const tier = m[2].charAt(0).toUpperCase() + m[2].slice(1).toLowerCase();
|
||||
const lite = m[3] ? ' Lite' : '';
|
||||
return `Gemini ${ver} ${tier}${lite}`;
|
||||
}
|
||||
const codenameMatch = s.match(/^gemini-(hydrogen|helix)$/i);
|
||||
if (codenameMatch) {
|
||||
const codename =
|
||||
codenameMatch[1].charAt(0).toUpperCase() + codenameMatch[1].slice(1).toLowerCase();
|
||||
return `Gemini ${codename}`;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
@@ -591,9 +591,13 @@ export async function syncCloudCatalog({ force = false, urls = CLOUD_CATALOG_URL
|
||||
|
||||
const statusAfter = getCloudStatus();
|
||||
const settings = loadSettings();
|
||||
const allowAutoUpdate =
|
||||
settings.pluginUpdateMode !== undefined
|
||||
? settings.pluginUpdateMode === 'auto'
|
||||
: Boolean(settings.autoUpdatePlugin);
|
||||
if (
|
||||
statusAfter.updateAvailable &&
|
||||
settings.autoUpdatePlugin &&
|
||||
allowAutoUpdate &&
|
||||
!pluginUpdateState.isUpdating &&
|
||||
pluginUpdateState.lastAutoAttemptVersion !== statusAfter.latestPluginVersion
|
||||
) {
|
||||
|
||||
@@ -145,7 +145,7 @@ export function compareSemver(a, b) {
|
||||
export function readInstalledPluginVersion() {
|
||||
const manifest = loadJson(PLUGIN_MANIFEST_FILE, null);
|
||||
const ver = typeof manifest?.version === 'string' ? manifest.version.trim() : '';
|
||||
return isValidSemver(ver) ? ver.replace(/^v/i, '') : '1.4.3';
|
||||
return isValidSemver(ver) ? ver.replace(/^v/i, '') : '1.4.4';
|
||||
}
|
||||
|
||||
function normalizeModelFamily(rawFamily) {
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>用量监控</title>
|
||||
<link rel="stylesheet" href="/styles.css?v=1794399833026">
|
||||
<link rel="stylesheet" href="/styles.css?v=1794408052910">
|
||||
<script src="/preload.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app-root"></div>
|
||||
<script src="/app.js?v=1794399833026"></script>
|
||||
<script src="/app.js?v=1794408052910"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+11
-4
@@ -22,6 +22,7 @@ import {
|
||||
computeRuntimeCodeVersion,
|
||||
isPlainObject,
|
||||
loadSettings,
|
||||
normalizePluginUpdateMode,
|
||||
normalizeTopbarCapsuleSlots,
|
||||
normalizeWeeklyLimitMode,
|
||||
saveJson,
|
||||
@@ -186,6 +187,14 @@ function sanitizePositiveSettingNumber(val, fallback) {
|
||||
function executeSettingsAction(data) {
|
||||
const current = loadSettings();
|
||||
const payload = isPlainObject(data) ? data : {};
|
||||
const nextPluginUpdateMode =
|
||||
payload.pluginUpdateMode !== undefined
|
||||
? normalizePluginUpdateMode(payload.pluginUpdateMode)
|
||||
: typeof payload.autoUpdatePlugin === 'boolean'
|
||||
? payload.autoUpdatePlugin
|
||||
? 'auto'
|
||||
: 'manual'
|
||||
: normalizePluginUpdateMode(current.pluginUpdateMode, current.autoUpdatePlugin);
|
||||
const updated = {
|
||||
weeklyTokenBudget: sanitizePositiveSettingNumber(
|
||||
payload.weeklyTokenBudget ?? payload.weeklyTokenLimit,
|
||||
@@ -203,10 +212,8 @@ function executeSettingsAction(data) {
|
||||
typeof payload.showUpstreamModel === 'boolean'
|
||||
? payload.showUpstreamModel
|
||||
: Boolean(current.showUpstreamModel),
|
||||
autoUpdatePlugin:
|
||||
typeof payload.autoUpdatePlugin === 'boolean'
|
||||
? payload.autoUpdatePlugin
|
||||
: Boolean(current.autoUpdatePlugin),
|
||||
pluginUpdateMode: nextPluginUpdateMode,
|
||||
autoUpdatePlugin: nextPluginUpdateMode === 'auto',
|
||||
enableWindowOverlay:
|
||||
typeof payload.enableWindowOverlay === 'boolean'
|
||||
? payload.enableWindowOverlay
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "usage-monitor-panel",
|
||||
"version": "1.4.3",
|
||||
"version": "1.4.4",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"description": "Sidecar backend and web UI for Antigravity Usage & Speed Monitor.",
|
||||
|
||||
@@ -215,7 +215,6 @@ export function createTrendAreaChart() {
|
||||
patchText(
|
||||
tipCostEl,
|
||||
formatUsd(slotCost, {
|
||||
unpricedCalls: slot.unpricedCalls,
|
||||
precise: slotCost > 0 && slotCost < 0.1,
|
||||
})
|
||||
);
|
||||
|
||||
@@ -9,6 +9,7 @@ import { h, patchAttr, patchClasses, patchText } from '../../core/domPatch.js';
|
||||
import { createSvgIcon, patchSvgIcon } from '../../icons/SvgIcon.js';
|
||||
import {
|
||||
fetchTelemetry,
|
||||
normalizeClientUpdateMode,
|
||||
telemetryStore,
|
||||
triggerPluginUpdate,
|
||||
} from '../../store/telemetryStore.js';
|
||||
@@ -175,9 +176,13 @@ export const TopSessionHeader = defineComponent({
|
||||
const aggregated = actConv?.aggregated;
|
||||
|
||||
const cloudStatus = telemetry?.cloudStatus;
|
||||
const hasUpdate = Boolean(cloudStatus?.updateAvailable);
|
||||
patchAttr(updateBtn, 'hidden', !hasUpdate);
|
||||
if (hasUpdate && !isHeaderUpdating) {
|
||||
const updateMode = normalizeClientUpdateMode(
|
||||
telemetry?.settings?.pluginUpdateMode,
|
||||
telemetry?.settings?.autoUpdatePlugin
|
||||
);
|
||||
const showUpdate = Boolean(cloudStatus?.updateAvailable) && updateMode !== 'off';
|
||||
patchAttr(updateBtn, 'hidden', !showUpdate);
|
||||
if (showUpdate && !isHeaderUpdating) {
|
||||
patchText(
|
||||
updateBtnText,
|
||||
cloudStatus?.latestPluginVersion
|
||||
|
||||
@@ -27,17 +27,19 @@ import {
|
||||
speedReasonText,
|
||||
} from '../../core/formatters.js';
|
||||
import { deliverCdpBridgeResponses, getWindowBridgeConfig } from '../../core/httpClient.js';
|
||||
import { createSvgIcon, SVG_NS } from '../../icons/SvgIcon.js';
|
||||
import { createSvgIcon, patchSvgIcon, SVG_NS } from '../../icons/SvgIcon.js';
|
||||
import {
|
||||
extractHostRouteCascadeId,
|
||||
fetchTelemetry,
|
||||
formatAgentLabel,
|
||||
getAgentBadgeClass,
|
||||
normalizeClientTopbarSlots,
|
||||
normalizeClientUpdateMode,
|
||||
resolveScopedConversation,
|
||||
startAsyncTelemetryLoop,
|
||||
stopAsyncTelemetryLoop,
|
||||
telemetryStore,
|
||||
triggerPluginUpdate,
|
||||
} from '../../store/telemetryStore.js';
|
||||
import { uiStore } from '../../store/uiStore.js';
|
||||
import {
|
||||
@@ -67,28 +69,30 @@ const RING_CIRCUMFERENCE = +(2 * Math.PI * RING_RADIUS).toFixed(2);
|
||||
export function computeCapsuleLayoutMode(availWidth, currentMode = 'wide', options = undefined) {
|
||||
if (availWidth == null || Number.isNaN(availWidth)) return 'wide';
|
||||
const showMulti = options?.showMulti !== false;
|
||||
const effWidth = showMulti ? availWidth : availWidth + 76;
|
||||
const updateReserve = options?.hasUpdate ? 52 : 0;
|
||||
const baseEffWidth = showMulti ? availWidth : availWidth + 76;
|
||||
const effWidth = baseEffWidth - updateReserve;
|
||||
if (currentMode === 'wide') {
|
||||
if (effWidth < 78) return 'ring-only';
|
||||
if (baseEffWidth < 78) return 'ring-only';
|
||||
if (effWidth < 196) return 'minimal';
|
||||
if (effWidth < 256) return 'compact';
|
||||
return 'wide';
|
||||
}
|
||||
if (currentMode === 'compact') {
|
||||
if (effWidth >= 272) return 'wide';
|
||||
if (effWidth < 78) return 'ring-only';
|
||||
if (baseEffWidth < 78) return 'ring-only';
|
||||
if (effWidth < 196) return 'minimal';
|
||||
return 'compact';
|
||||
}
|
||||
if (currentMode === 'minimal') {
|
||||
if (effWidth >= 272) return 'wide';
|
||||
if (effWidth >= 212) return 'compact';
|
||||
if (effWidth < 78) return 'ring-only';
|
||||
if (baseEffWidth < 78) return 'ring-only';
|
||||
return 'minimal';
|
||||
}
|
||||
if (effWidth >= 272) return 'wide';
|
||||
if (effWidth >= 212) return 'compact';
|
||||
if (effWidth >= 92) return 'minimal';
|
||||
if (baseEffWidth >= 92) return 'minimal';
|
||||
return 'ring-only';
|
||||
}
|
||||
|
||||
@@ -372,9 +376,16 @@ export function mountWindowOverlay() {
|
||||
}
|
||||
const r = capsuleBtn.getBoundingClientRect();
|
||||
if (r.width <= 0 || r.height <= 0) return false;
|
||||
let rightBound = r.right;
|
||||
if (!topbarUpdateBtn.hasAttribute('hidden') && topbarUpdateBtn.getBoundingClientRect) {
|
||||
const ur = topbarUpdateBtn.getBoundingClientRect();
|
||||
if (ur.width > 0 && ur.height > 0) {
|
||||
rightBound = Math.max(rightBound, ur.right);
|
||||
}
|
||||
}
|
||||
return (
|
||||
lastPointerX >= r.left - 1 &&
|
||||
lastPointerX <= r.right + 1 &&
|
||||
lastPointerX <= rightBound + 1 &&
|
||||
lastPointerY >= r.top - 1 &&
|
||||
lastPointerY <= r.bottom + 1
|
||||
);
|
||||
@@ -606,8 +617,87 @@ export function mountWindowOverlay() {
|
||||
const sep0 = h('span', { className: 'wm-sep wm-sep-speed', 'data-sep-for-rank': '2' });
|
||||
const sep1 = h('span', { className: 'wm-sep wm-sep-quota', 'data-sep-for-rank': '3' });
|
||||
let lastShowMulti = true;
|
||||
let lastShowUpdate = false;
|
||||
let isTopbarUpdating = false;
|
||||
|
||||
const updateDot = h('span', { className: 'wm-update-dot', hidden: true });
|
||||
const topbarUpdateIcon = createSvgIcon('arrow-down', { size: 10 });
|
||||
const topbarUpdateLabel = h('span', { className: 'wm-update-label', text: '新版本' });
|
||||
const topbarUpdateBtn = h(
|
||||
'button',
|
||||
{
|
||||
type: 'button',
|
||||
className: 'wm-update-btn',
|
||||
hidden: true,
|
||||
'aria-label': '发现新版本,点击更新',
|
||||
title: '发现新版本,点击立即更新',
|
||||
onClick: async (e) => {
|
||||
e.stopPropagation();
|
||||
if (isTopbarUpdating) return;
|
||||
isTopbarUpdating = true;
|
||||
patchClasses(topbarUpdateBtn, { 'is-updating': true });
|
||||
patchSvgIcon(topbarUpdateIcon, 'refresh');
|
||||
patchText(topbarUpdateLabel, '更新中…');
|
||||
patchAttr(topbarUpdateBtn, 'disabled', true);
|
||||
try {
|
||||
const res = await triggerPluginUpdate();
|
||||
if (!res?.ok) {
|
||||
uiStore.setState({ activeView: 'settings' });
|
||||
setPopoverOpen(true);
|
||||
}
|
||||
} catch {
|
||||
uiStore.setState({ activeView: 'settings' });
|
||||
setPopoverOpen(true);
|
||||
} finally {
|
||||
isTopbarUpdating = false;
|
||||
patchClasses(topbarUpdateBtn, { 'is-updating': false });
|
||||
patchSvgIcon(topbarUpdateIcon, 'arrow-down');
|
||||
patchAttr(topbarUpdateBtn, 'disabled', false);
|
||||
const cs = telemetryStore.getState().telemetry?.cloudStatus;
|
||||
patchText(
|
||||
topbarUpdateLabel,
|
||||
cs?.latestPluginVersion ? `v${cs.latestPluginVersion}` : '新版本'
|
||||
);
|
||||
}
|
||||
},
|
||||
onMouseenter: (e) => {
|
||||
recordPointerCoords(e);
|
||||
if (hoverLeaveTimer) {
|
||||
clearTimeout(hoverLeaveTimer);
|
||||
hoverLeaveTimer = null;
|
||||
}
|
||||
if (!popoverOpen && !multiPinned) {
|
||||
if (multiOpen) {
|
||||
setMultiOpen(false);
|
||||
}
|
||||
setTooltipOpen(true);
|
||||
}
|
||||
},
|
||||
onMouseleave: (e) => {
|
||||
recordPointerCoords(e);
|
||||
if (hoverLeaveTimer) {
|
||||
clearTimeout(hoverLeaveTimer);
|
||||
}
|
||||
hoverLeaveTimer = setTimeout(() => {
|
||||
hoverLeaveTimer = null;
|
||||
if (disposed || popoverOpen) return;
|
||||
let nativeHover = false;
|
||||
try {
|
||||
nativeHover = Boolean(
|
||||
capsuleBtn.matches?.(':hover') || topbarUpdateBtn.matches?.(':hover')
|
||||
);
|
||||
} catch {
|
||||
nativeHover = false;
|
||||
}
|
||||
if (nativeHover || isPointerStillInCapsule()) {
|
||||
return;
|
||||
}
|
||||
setTooltipOpen(false);
|
||||
}, 40);
|
||||
},
|
||||
},
|
||||
[topbarUpdateIcon, topbarUpdateLabel]
|
||||
);
|
||||
|
||||
const capsuleBtn = h(
|
||||
'button',
|
||||
@@ -648,7 +738,9 @@ export function mountWindowOverlay() {
|
||||
if (disposed || popoverOpen) return;
|
||||
let nativeHover = false;
|
||||
try {
|
||||
nativeHover = Boolean(capsuleBtn.matches?.(':hover'));
|
||||
nativeHover = Boolean(
|
||||
capsuleBtn.matches?.(':hover') || topbarUpdateBtn.matches?.(':hover')
|
||||
);
|
||||
} catch {
|
||||
nativeHover = false;
|
||||
}
|
||||
@@ -663,6 +755,7 @@ export function mountWindowOverlay() {
|
||||
);
|
||||
capsuleShadow.appendChild(multiBtn);
|
||||
capsuleShadow.appendChild(capsuleBtn);
|
||||
capsuleShadow.appendChild(topbarUpdateBtn);
|
||||
|
||||
// --- 2. 创建 Body 顶层浮层 Portal Shadow Host ---
|
||||
const portalHost = document.createElement('div');
|
||||
@@ -789,13 +882,33 @@ export function mountWindowOverlay() {
|
||||
]),
|
||||
]);
|
||||
|
||||
const hoverUpdateVerText = h('span', { text: '发现新版本' });
|
||||
const hoverUpdateHintText = h('span', {
|
||||
className: 'wm-hover-update-hint',
|
||||
text: '点击顶栏版本胶囊即可一键更新',
|
||||
});
|
||||
const hoverUpdateBar = h(
|
||||
'div',
|
||||
{
|
||||
className: 'wm-hover-update-bar',
|
||||
hidden: true,
|
||||
},
|
||||
[
|
||||
h('span', { className: 'wm-hover-update-left' }, [
|
||||
createSvgIcon('arrow-down', { size: 11 }),
|
||||
hoverUpdateVerText,
|
||||
]),
|
||||
hoverUpdateHintText,
|
||||
]
|
||||
);
|
||||
|
||||
const hoverTipEl = h(
|
||||
'div',
|
||||
{
|
||||
className: 'wm-hover-tip',
|
||||
hidden: true,
|
||||
},
|
||||
[hoverMatrixEl, hoverCtxPanel, hoverQuotaPanel]
|
||||
[hoverUpdateBar, hoverMatrixEl, hoverCtxPanel, hoverQuotaPanel]
|
||||
);
|
||||
|
||||
// 左侧多会话实时看板浮层(活跃运行会话卡片 + 近期多窗口会话速览,全槽位预占、就地补丁更新)
|
||||
@@ -896,16 +1009,11 @@ export function mountWindowOverlay() {
|
||||
|
||||
const multiPinBadge = h('span', { className: 'wm-pin-badge', hidden: true, text: '已固定' });
|
||||
const multiRunningMetaEl = h('span', { className: 'panel-meta text-mono', text: '读取中...' });
|
||||
const multiEmptyHintEl = h('span', {
|
||||
className: 'wm-multi-empty-hint',
|
||||
text: '悬停速览 · 左键固定',
|
||||
});
|
||||
const multiEmptyEl = h('div', { className: 'wm-multi-empty' }, [
|
||||
h('span', { className: 'wm-multi-empty-left' }, [
|
||||
h('span', { className: 'wm-idle-dot' }),
|
||||
h('span', { text: '当前暂无在线运行的会话' }),
|
||||
]),
|
||||
multiEmptyHintEl,
|
||||
]);
|
||||
const multiRunningListEl = h('div', {
|
||||
className: 'live-activity-list',
|
||||
@@ -1079,6 +1187,11 @@ export function mountWindowOverlay() {
|
||||
multiPanelEl.style.maxHeight = `${Math.max(240, vh - top - 12)}px`;
|
||||
}
|
||||
|
||||
const rightAnchorEdge =
|
||||
!topbarUpdateBtn.hasAttribute('hidden') && topbarUpdateBtn.getBoundingClientRect
|
||||
? Math.max(bRect.right, topbarUpdateBtn.getBoundingClientRect().right || 0)
|
||||
: bRect.right;
|
||||
|
||||
if (popoverOpen) {
|
||||
const rawW =
|
||||
Number(popoverEl.offsetWidth) ||
|
||||
@@ -1086,7 +1199,7 @@ export function mountWindowOverlay() {
|
||||
defaultCardW;
|
||||
const panelW = Math.min(rawW, Math.max(280, vw - minLeft - 12));
|
||||
const top = Math.max(38, Math.min(vh - 140, Math.round(bRect.bottom + 6)));
|
||||
let left = Math.round(bRect.right - panelW);
|
||||
let left = Math.round(rightAnchorEdge - panelW);
|
||||
left = Math.min(left, vw - panelW - 12);
|
||||
left = Math.max(minLeft, left);
|
||||
popoverEl.style.top = `${top}px`;
|
||||
@@ -1108,7 +1221,7 @@ export function mountWindowOverlay() {
|
||||
if (top + tipH > vh - 8 && bRect.top > tipH + 12) {
|
||||
top = Math.round(bRect.top - tipH - 6);
|
||||
}
|
||||
let left = Math.round(bRect.right - tipW);
|
||||
let left = Math.round(rightAnchorEdge - tipW);
|
||||
left = Math.min(left, vw - tipW - 12);
|
||||
left = Math.max(minLeft, left);
|
||||
hoverTipEl.style.top = `${top}px`;
|
||||
@@ -1124,9 +1237,14 @@ export function mountWindowOverlay() {
|
||||
if (disposed) return;
|
||||
const titlebar = findHostTitlebar();
|
||||
const avail = measureAvailableTitlebarWidth(titlebar);
|
||||
const showMulti =
|
||||
telemetryStore.getState().telemetry?.settings?.showTopbarMultiSession !== false;
|
||||
const nextMode = computeCapsuleLayoutMode(avail, layoutMode, { showMulti });
|
||||
const curTel = telemetryStore.getState().telemetry;
|
||||
const showMulti = curTel?.settings?.showTopbarMultiSession !== false;
|
||||
const curUpdateMode = normalizeClientUpdateMode(
|
||||
curTel?.settings?.pluginUpdateMode,
|
||||
curTel?.settings?.autoUpdatePlugin
|
||||
);
|
||||
const hasUpdate = Boolean(curTel?.cloudStatus?.updateAvailable) && curUpdateMode !== 'off';
|
||||
const nextMode = computeCapsuleLayoutMode(avail, layoutMode, { showMulti, hasUpdate });
|
||||
if (nextMode !== layoutMode) {
|
||||
layoutMode = nextMode;
|
||||
capsuleHost.setAttribute('data-layout', layoutMode);
|
||||
@@ -1608,7 +1726,6 @@ export function mountWindowOverlay() {
|
||||
: `${runningCount} 个会话运行中`
|
||||
: '全部待命'
|
||||
);
|
||||
patchText(multiEmptyHintEl, '悬停速览 · 左键可固定');
|
||||
patchAttr(multiEmptyEl, 'hidden', runningCount > 0);
|
||||
patchAttr(multiRunningListEl, 'hidden', runningCount === 0);
|
||||
|
||||
@@ -1839,8 +1956,38 @@ export function mountWindowOverlay() {
|
||||
quotas: telemetry.quotas,
|
||||
});
|
||||
|
||||
const hasUpdate = Boolean(telemetry.cloudStatus?.updateAvailable);
|
||||
patchAttr(updateDot, 'hidden', !hasUpdate);
|
||||
const updateMode = normalizeClientUpdateMode(
|
||||
telemetry.settings?.pluginUpdateMode,
|
||||
telemetry.settings?.autoUpdatePlugin
|
||||
);
|
||||
const showUpdatePrompt =
|
||||
Boolean(telemetry.cloudStatus?.updateAvailable) && updateMode !== 'off';
|
||||
const latestVer = telemetry.cloudStatus?.latestPluginVersion || '';
|
||||
patchAttr(updateDot, 'hidden', !showUpdatePrompt);
|
||||
patchAttr(topbarUpdateBtn, 'hidden', !showUpdatePrompt);
|
||||
patchAttr(hoverUpdateBar, 'hidden', !showUpdatePrompt);
|
||||
if (showUpdatePrompt) {
|
||||
if (!isTopbarUpdating) {
|
||||
patchText(topbarUpdateLabel, latestVer ? `v${latestVer}` : '新版本');
|
||||
}
|
||||
patchAttr(
|
||||
topbarUpdateBtn,
|
||||
'title',
|
||||
latestVer ? `发现新版本 v${latestVer},左键立即更新` : '发现新版本,左键立即更新'
|
||||
);
|
||||
patchText(
|
||||
hoverUpdateVerText,
|
||||
latestVer ? `发现新版本 v${latestVer}` : '发现新版本可用'
|
||||
);
|
||||
patchText(
|
||||
hoverUpdateHintText,
|
||||
latestVer ? `点击顶栏 v${latestVer} 即可更新` : '点击顶栏版本胶囊即可更新'
|
||||
);
|
||||
}
|
||||
if (showUpdatePrompt !== lastShowUpdate) {
|
||||
lastShowUpdate = showUpdatePrompt;
|
||||
updateResponsiveLayout();
|
||||
}
|
||||
|
||||
// --- 同步悬停三卡片全景概览(与 LiveOverviewView 保持完全一致的数据口径与视觉呈现) ---
|
||||
const showUpstream = Boolean(telemetry.settings?.showUpstreamModel);
|
||||
@@ -1872,7 +2019,7 @@ export function mountWindowOverlay() {
|
||||
);
|
||||
patchText(
|
||||
hoverCacheSub,
|
||||
`缓存 ${overviewActive.latestCacheHitPct ?? 0}% · 累计 ${formatUsd(overviewActive.sessionCostUsd || 0, { unpricedCalls: overviewActive.sessionUnpricedCalls })}`
|
||||
`缓存 ${overviewActive.latestCacheHitPct ?? 0}% · 累计 ${formatUsd(overviewActive.sessionCostUsd || 0)}`
|
||||
);
|
||||
|
||||
patchAttr(hoverCtxAgentBadge, 'hidden', !(hasSubagents && ctxAgent));
|
||||
@@ -1917,7 +2064,7 @@ export function mountWindowOverlay() {
|
||||
});
|
||||
patchText(
|
||||
hoverWkFootLeft,
|
||||
`本周累计: ${formatTokens(weekly.tokens || 0)} (${formatUsd(weekly.costUsd || 0, { unpricedCalls: weekly.unpricedCalls })})`
|
||||
`本周累计: ${formatTokens(weekly.tokens || 0)} (${formatUsd(weekly.costUsd || 0)})`
|
||||
);
|
||||
patchText(
|
||||
hoverWkFootRight,
|
||||
|
||||
@@ -163,7 +163,9 @@ export const CustomSelect = defineComponent({
|
||||
const matchedOpt = options.find((o) => o.value === modelValue);
|
||||
const selectedOpt = matchedOpt || (!modelValue ? options[0] : undefined);
|
||||
const fallbackText = modelValue ? `${placeholder} (${String(modelValue).slice(0, 8)})` : placeholder;
|
||||
patchText(triggerLabel, selectedOpt ? selectedOpt.label : fallbackText);
|
||||
const labelText = selectedOpt ? selectedOpt.label : fallbackText;
|
||||
patchText(triggerLabel, labelText);
|
||||
patchAttr(triggerBtn, 'title', labelText);
|
||||
if (isOpen) {
|
||||
renderMenuOptions();
|
||||
}
|
||||
|
||||
@@ -37,15 +37,14 @@ export function formatDateSpanBadge(startMs, endMs) {
|
||||
return `${s.getMonth() + 1}月${s.getDate()}日 ~ ${e.getMonth() + 1}月${e.getDate()}日`;
|
||||
}
|
||||
|
||||
export function formatUsd(amount, { precise = false, unpricedCalls = 0, compactPending = false } = {}) {
|
||||
export function formatUsd(amount, { precise = false } = {}) {
|
||||
if (amount == null || !Number.isFinite(Number(amount))) return '待定';
|
||||
const val = Number(amount || 0);
|
||||
const suffix = unpricedCalls > 0 ? (compactPending ? '+' : ' + 待定') : '';
|
||||
if (precise) {
|
||||
if (val > 0 && val < 0.001) return `<$0.001${suffix}`;
|
||||
return (val >= 1 ? `$${val.toFixed(2)}` : `$${val.toFixed(3)}`) + suffix;
|
||||
if (val > 0 && val < 0.001) return '<$0.001';
|
||||
return val >= 1 ? `$${val.toFixed(2)}` : `$${val.toFixed(3)}`;
|
||||
}
|
||||
return `$${val.toFixed(2)}${suffix}`;
|
||||
return `$${val.toFixed(2)}`;
|
||||
}
|
||||
|
||||
export function speedReasonText(reason) {
|
||||
|
||||
@@ -78,6 +78,9 @@ export const SVG_ICON_DEFS = Object.freeze({
|
||||
'arrow-down': [
|
||||
{ tag: 'path', attrs: { d: 'M8 2.8v10.4M4.2 9.4L8 13.2l3.8-3.8' } },
|
||||
],
|
||||
'arrow-up': [
|
||||
{ tag: 'path', attrs: { d: 'M8 13.2V2.8M4.2 6.6L8 2.8l3.8 3.8' } },
|
||||
],
|
||||
dock: [
|
||||
{ tag: 'rect', attrs: { x: '1.8', y: '2.5', width: '12.4', height: '11', rx: '1.5' } },
|
||||
{ tag: 'path', attrs: { d: 'M1.8 6h12.4' } },
|
||||
|
||||
@@ -74,17 +74,32 @@ export function normalizeClientTopbarSlots(raw) {
|
||||
return slots;
|
||||
}
|
||||
|
||||
/**
|
||||
* 归一化前端插件更新策略(`'off'` | `'manual'` | `'auto'`),兼容旧版布尔字段。
|
||||
*
|
||||
* @param {unknown} mode
|
||||
* @param {unknown} [legacyAutoUpdate]
|
||||
* @returns {'off'|'manual'|'auto'}
|
||||
*/
|
||||
export function normalizeClientUpdateMode(mode, legacyAutoUpdate) {
|
||||
const m = String(mode ?? '').trim().toLowerCase();
|
||||
if (m === 'off' || m === 'manual' || m === 'auto') return m;
|
||||
if (legacyAutoUpdate === true) return 'auto';
|
||||
return 'manual';
|
||||
}
|
||||
|
||||
function isEquivalentTelemetry(prev, next) {
|
||||
if (!prev || !next) return false;
|
||||
if (prev === next) return true;
|
||||
|
||||
// 1. 比对系统设置项(模型显示策略、周预算模式与额度、插件自动更新开关、双栖与顶栏槽位配置)
|
||||
// 1. 比对系统设置项(模型显示策略、周预算模式与额度、插件更新策略、双栖与顶栏槽位配置)
|
||||
const pAct = prev.activeConversation;
|
||||
const nAct = next.activeConversation;
|
||||
if (prev.settings?.showUpstreamModel !== next.settings?.showUpstreamModel) return false;
|
||||
if (prev.settings?.weeklyLimitMode !== next.settings?.weeklyLimitMode) return false;
|
||||
if (prev.settings?.weeklyTokenBudget !== next.settings?.weeklyTokenBudget) return false;
|
||||
if (prev.settings?.weeklyCostBudget !== next.settings?.weeklyCostBudget) return false;
|
||||
if ((prev.settings?.pluginUpdateMode ?? '') !== (next.settings?.pluginUpdateMode ?? '')) return false;
|
||||
if (prev.settings?.autoUpdatePlugin !== next.settings?.autoUpdatePlugin) return false;
|
||||
if (prev.settings?.enableWindowOverlay !== next.settings?.enableWindowOverlay) return false;
|
||||
if ((prev.settings?.showTopbarMultiSession !== false) !== (next.settings?.showTopbarMultiSession !== false)) {
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
.steps-inline-scope-select .select-menu {
|
||||
left: auto;
|
||||
right: 0;
|
||||
min-width: 220px;
|
||||
max-width: min(320px, 82vw);
|
||||
}
|
||||
|
||||
.session-left {
|
||||
|
||||
@@ -78,6 +78,7 @@
|
||||
}
|
||||
|
||||
.wm-multi-btn[hidden],
|
||||
.wm-update-btn[hidden],
|
||||
.wm-cap-slot[hidden],
|
||||
.wm-sep[hidden] {
|
||||
display: none !important;
|
||||
@@ -299,7 +300,7 @@
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
/* 右上角绝对定位更新圆点,不参与文档流,零宽度抖动 */
|
||||
/* 仅在超窄 ring-only 折叠态下使用右上角 5px 提示圆点;常规态由柔和微胶囊 .wm-update-btn 承载 */
|
||||
.wm-update-dot {
|
||||
position: absolute;
|
||||
top: 3px;
|
||||
@@ -307,10 +308,83 @@
|
||||
width: 5px;
|
||||
height: 5px;
|
||||
border-radius: var(--radius-pill);
|
||||
background: var(--metric-ok);
|
||||
background: var(--accent-primary);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
:host(.wm-capsule-host:not([data-layout="ring-only"])) .wm-update-dot {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
/* 顶栏右侧柔和半透明新版本胶囊按钮(20px 矮胶囊嵌套于 28px 顶栏,克制不突兀,左键一键升级) */
|
||||
.wm-update-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 3px;
|
||||
height: 20px;
|
||||
padding: 0 6px 0 5px;
|
||||
margin: 0;
|
||||
background: color-mix(in srgb, var(--accent-primary) 10%, transparent);
|
||||
color: var(--accent-primary);
|
||||
border: 1px solid color-mix(in srgb, var(--accent-primary) 24%, transparent);
|
||||
border-radius: var(--radius-pill);
|
||||
font-family: inherit;
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
line-height: 18px;
|
||||
letter-spacing: 0.01em;
|
||||
font-variant-numeric: tabular-nums;
|
||||
white-space: nowrap;
|
||||
flex-shrink: 0;
|
||||
cursor: pointer;
|
||||
-webkit-app-region: no-drag;
|
||||
transition:
|
||||
background-color var(--dur-instant) var(--ease-fast),
|
||||
border-color var(--dur-instant) var(--ease-fast),
|
||||
transform var(--dur-instant) var(--ease-fast);
|
||||
}
|
||||
|
||||
.wm-update-btn:hover:not(:disabled) {
|
||||
background: color-mix(in srgb, var(--accent-primary) 18%, transparent);
|
||||
border-color: color-mix(in srgb, var(--accent-primary) 40%, transparent);
|
||||
}
|
||||
|
||||
.wm-update-btn:active:not(:disabled) {
|
||||
transform: scale(0.96);
|
||||
}
|
||||
|
||||
.wm-update-btn:disabled {
|
||||
opacity: 0.72;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
@keyframes wm-spin-icon {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
.wm-update-btn.is-updating .svg-icon {
|
||||
animation: wm-spin-icon 0.9s linear infinite;
|
||||
}
|
||||
|
||||
:host(.wm-capsule-host[data-layout="minimal"]) .wm-update-label {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
:host(.wm-capsule-host[data-layout="minimal"]) .wm-update-btn {
|
||||
width: 20px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
:host(.wm-capsule-host[data-layout="ring-only"]) .wm-update-btn {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
/* 四级响应式迟滞折叠(基于可见槽位次序 data-vis-rank 与分隔线次序 data-sep-for-rank 动态折叠) */
|
||||
:host(.wm-capsule-host[data-layout="compact"]) .wm-cap-slot[data-vis-rank="3"],
|
||||
:host(.wm-capsule-host[data-layout="compact"]) .wm-sep[data-sep-for-rank="3"] {
|
||||
@@ -471,6 +545,36 @@
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.wm-hover-update-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: var(--space-2);
|
||||
padding: 5px 10px;
|
||||
border-radius: var(--radius-xs);
|
||||
background: var(--accent-primary-soft);
|
||||
border: 1px solid var(--accent-primary-border);
|
||||
font-size: 11.5px;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.wm-hover-update-left {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
color: var(--accent-primary);
|
||||
font-weight: 600;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.wm-hover-update-hint {
|
||||
color: var(--text-secondary);
|
||||
font-size: 11px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.wm-hover-quota-pools {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -580,10 +684,3 @@
|
||||
background: color-mix(in srgb, var(--text-secondary) 38%, transparent);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.wm-multi-empty-hint {
|
||||
font-size: 11px;
|
||||
color: var(--text-muted);
|
||||
white-space: nowrap;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
@@ -66,21 +66,40 @@
|
||||
background: var(--surface-hover);
|
||||
}
|
||||
|
||||
.steps-panel-header {
|
||||
flex-wrap: wrap;
|
||||
row-gap: 6px;
|
||||
}
|
||||
|
||||
.steps-panel-title {
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
.steps-header-controls {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 6px;
|
||||
flex-wrap: wrap;
|
||||
flex: 1 1 280px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.steps-header-controls .segmented {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.steps-inline-scope-select {
|
||||
flex: 1 1 120px;
|
||||
min-width: 120px;
|
||||
flex: 0 1 180px;
|
||||
min-width: 72px;
|
||||
max-width: 190px;
|
||||
}
|
||||
|
||||
.steps-inline-scope-select .select-trigger {
|
||||
height: 22px;
|
||||
padding: 0 6px;
|
||||
gap: 4px;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
font-size: 11px;
|
||||
border: 1px solid var(--border-hairline);
|
||||
background: var(--surface-subtle);
|
||||
|
||||
@@ -417,7 +417,7 @@ export const ConsumptionView = defineComponent({
|
||||
patchText(refs.pctBadge, `${share.toFixed(1)}%`);
|
||||
patchText(refs.totalTokEl, showTokensInHeader ? formatTokensPrecise(total) : '');
|
||||
patchAttr(refs.totalTokEl, 'hidden', !showTokensInHeader);
|
||||
patchText(refs.costEl, formatUsd(item.costUsd || 0, { unpricedCalls: item.unpricedCalls }));
|
||||
patchText(refs.costEl, formatUsd(item.costUsd || 0));
|
||||
|
||||
const responseTok =
|
||||
item.responseTokens != null
|
||||
@@ -477,8 +477,8 @@ export const ConsumptionView = defineComponent({
|
||||
|
||||
patchText(heroTotalTokens, formatTokensPrecise(totalTokens));
|
||||
patchText(heroTotalCalls, `${acct.calls || 0} 次`);
|
||||
patchText(heroCostUsd, formatUsd(costUsd, { unpricedCalls: acct.unpricedCalls }));
|
||||
patchText(heroCostCny, acct.unpricedCalls > 0 ? `${acct.unpricedCalls} 步费用待定` : formatCnyApprox(costUsd));
|
||||
patchText(heroCostUsd, formatUsd(costUsd));
|
||||
patchText(heroCostCny, formatCnyApprox(costUsd));
|
||||
|
||||
patchText(cacheHitPctEl, `${Number(acct.cacheHitPct ?? 0).toFixed(1)}%`);
|
||||
patchText(cacheTokensEl, `命中 ${formatTokensPrecise(cacheTokens)}`);
|
||||
@@ -602,11 +602,7 @@ export const ConsumptionView = defineComponent({
|
||||
const cVal = Number(m.costUsd || 0);
|
||||
patchText(
|
||||
col.costText,
|
||||
m.unpricedCalls > 0
|
||||
? formatUsd(cVal, { unpricedCalls: m.unpricedCalls, compactPending: true })
|
||||
: cVal >= 10
|
||||
? `$${Math.round(cVal)}`
|
||||
: `$${cVal.toFixed(2)}`
|
||||
cVal >= 10 ? `$${Math.round(cVal)}` : `$${cVal.toFixed(2)}`
|
||||
);
|
||||
patchText(col.tokText, formatTokensPrecise(mTot));
|
||||
|
||||
|
||||
@@ -889,7 +889,7 @@ export const LiveOverviewView = defineComponent({
|
||||
);
|
||||
patchText(
|
||||
cacheSub,
|
||||
`缓存 ${active.latestCacheHitPct ?? 0}% · 累计 ${formatUsd(active.sessionCostUsd || 0, { unpricedCalls: active.sessionUnpricedCalls })}`
|
||||
`缓存 ${active.latestCacheHitPct ?? 0}% · 累计 ${formatUsd(active.sessionCostUsd || 0)}`
|
||||
);
|
||||
|
||||
// 2. 更新 10 段上下文窗口构成与内嵌上下文窗口检视胶囊条
|
||||
@@ -1051,7 +1051,7 @@ export const LiveOverviewView = defineComponent({
|
||||
|
||||
patchText(
|
||||
wkFootLeft,
|
||||
`本周累计: ${formatTokens(weekly.tokens || 0)} (${formatUsd(weekly.costUsd || 0, { unpricedCalls: weekly.unpricedCalls })})`
|
||||
`本周累计: ${formatTokens(weekly.tokens || 0)} (${formatUsd(weekly.costUsd || 0)})`
|
||||
);
|
||||
patchText(
|
||||
wkFootRight,
|
||||
|
||||
@@ -12,6 +12,7 @@ import { createSvgIcon } from '../icons/SvgIcon.js';
|
||||
import {
|
||||
DEFAULT_CLIENT_TOPBAR_SLOTS,
|
||||
normalizeClientTopbarSlots,
|
||||
normalizeClientUpdateMode,
|
||||
saveSettingsPatch,
|
||||
telemetryStore,
|
||||
triggerCloudSync,
|
||||
@@ -54,10 +55,11 @@ const TOPBAR_SLOT_OPTIONS = [
|
||||
{ value: 'none', label: '不显示' },
|
||||
];
|
||||
|
||||
/** 插件版本更新策略可选项 */
|
||||
/** 插件版本更新策略可选项(默认仅提示新版本、手动更新) */
|
||||
const AUTO_UPDATE_OPTIONS = [
|
||||
{ value: 'manual', label: '仅提示新版本,手动更新 (推荐)' },
|
||||
{ value: 'auto', label: '后台自动安装新版本' },
|
||||
{ value: 'manual', label: '仅提示新版本,手动更新' },
|
||||
{ value: 'auto', label: '自动更新' },
|
||||
{ value: 'off', label: '关闭更新' },
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -79,7 +81,7 @@ export const SettingsView = defineComponent({
|
||||
name: 'SettingsView',
|
||||
setup({ onCleanup }) {
|
||||
let draftShowUpstreamModel = false;
|
||||
let draftAutoUpdatePlugin = false;
|
||||
let draftPluginUpdateMode = 'manual';
|
||||
let draftEnableWindowOverlay = true;
|
||||
let draftShowTopbarMulti = true;
|
||||
let draftTopbarSlots = [...DEFAULT_CLIENT_TOPBAR_SLOTS];
|
||||
@@ -375,19 +377,26 @@ export const SettingsView = defineComponent({
|
||||
icon: 'refresh',
|
||||
options: AUTO_UPDATE_OPTIONS,
|
||||
onUpdateModelValue: async (val) => {
|
||||
const nextAuto = val === 'auto';
|
||||
draftAutoUpdatePlugin = nextAuto;
|
||||
autoUpdateSelect.setValue(nextAuto ? 'auto' : 'manual');
|
||||
const nextMode = normalizeClientUpdateMode(val);
|
||||
draftPluginUpdateMode = nextMode;
|
||||
autoUpdateSelect.setValue(nextMode);
|
||||
if (latestCloudStatus) {
|
||||
renderCloudStatus(latestCloudStatus);
|
||||
}
|
||||
showCloudFeedback('保存中…', 0);
|
||||
try {
|
||||
await saveSettingsPatch({
|
||||
autoUpdatePlugin: nextAuto,
|
||||
pluginUpdateMode: nextMode,
|
||||
autoUpdatePlugin: nextMode === 'auto',
|
||||
});
|
||||
showCloudFeedback('已保存', 1800);
|
||||
} catch {
|
||||
if (latestSettings) {
|
||||
renderSettings(latestSettings);
|
||||
}
|
||||
if (latestCloudStatus) {
|
||||
renderCloudStatus(latestCloudStatus);
|
||||
}
|
||||
showCloudFeedback('保存失败', 2500);
|
||||
}
|
||||
},
|
||||
@@ -395,7 +404,7 @@ export const SettingsView = defineComponent({
|
||||
|
||||
const pricingCountVal = h('strong', { className: 'cell-value', text: '—' });
|
||||
const pricingSyncSub = h('span', { className: 'cell-sub', text: '读取中…' });
|
||||
const versionVal = h('strong', { className: 'cell-value', text: 'v1.4.3' });
|
||||
const versionVal = h('strong', { className: 'cell-value', text: 'v1.4.4' });
|
||||
const versionSub = h('span', { className: 'cell-sub', text: '检查中…' });
|
||||
|
||||
const syncPricingBtnText = h('span', { text: '更新价格表' });
|
||||
@@ -450,7 +459,7 @@ export const SettingsView = defineComponent({
|
||||
return;
|
||||
}
|
||||
if (!cs?.updateAvailable) {
|
||||
const curVer = cs?.currentPluginVersion || '1.4.3';
|
||||
const curVer = cs?.currentPluginVersion || '1.4.4';
|
||||
showCloudFeedback(`当前已是最新版本 (v${curVer})`, 4500);
|
||||
return;
|
||||
}
|
||||
@@ -486,7 +495,7 @@ export const SettingsView = defineComponent({
|
||||
cloudStatusMsg,
|
||||
]),
|
||||
h('div', { className: 'form-row' }, [
|
||||
h('span', { className: 'form-label', text: '自动更新' }),
|
||||
h('span', { className: 'form-label', text: '更新方式' }),
|
||||
autoUpdateSelect.el,
|
||||
]),
|
||||
h('div', { className: 'dual-grid' }, [
|
||||
@@ -523,14 +532,17 @@ export const SettingsView = defineComponent({
|
||||
function renderSettings(settings) {
|
||||
if (!settings) return;
|
||||
draftShowUpstreamModel = Boolean(settings.showUpstreamModel);
|
||||
draftAutoUpdatePlugin = Boolean(settings.autoUpdatePlugin);
|
||||
draftPluginUpdateMode = normalizeClientUpdateMode(
|
||||
settings.pluginUpdateMode,
|
||||
settings.autoUpdatePlugin
|
||||
);
|
||||
draftEnableWindowOverlay = settings.enableWindowOverlay !== false;
|
||||
draftShowTopbarMulti = settings.showTopbarMultiSession !== false;
|
||||
draftTopbarSlots = normalizeClientTopbarSlots(settings.topbarCapsuleSlots);
|
||||
|
||||
windowMountSelect.setValue(draftEnableWindowOverlay ? 'dual' : 'sidebar');
|
||||
stepModelSelect.setValue(draftShowUpstreamModel ? 'upstream' : 'short');
|
||||
autoUpdateSelect.setValue(draftAutoUpdatePlugin ? 'auto' : 'manual');
|
||||
autoUpdateSelect.setValue(draftPluginUpdateMode);
|
||||
syncTopbarControls();
|
||||
viewScrollbar.refresh();
|
||||
}
|
||||
@@ -550,15 +562,20 @@ export const SettingsView = defineComponent({
|
||||
`${srcLabel} · ${formatSyncTimeText(cs.lastSyncedAtMs, cs.catalogUpdatedAt)}`
|
||||
);
|
||||
|
||||
const curVer = cs.currentPluginVersion || '1.4.3';
|
||||
const curVer = cs.currentPluginVersion || '1.4.4';
|
||||
const latVer = cs.latestPluginVersion || curVer;
|
||||
const modeTag = cs.installMode === 'git' ? 'Git' : 'ZIP';
|
||||
patchText(versionVal, `v${curVer}`);
|
||||
if (cs.updateAvailable) {
|
||||
if (cs.updateAvailable && draftPluginUpdateMode !== 'off') {
|
||||
patchText(versionSub, `可升级至 v${latVer} (${modeTag})`);
|
||||
patchClasses(versionSub, { 'accent-ok': true });
|
||||
patchText(updatePluginBtnText, `升级至 v${latVer}`);
|
||||
patchClasses(updatePluginBtn, { 'btn-primary': true, 'btn-secondary': false });
|
||||
} else if (draftPluginUpdateMode === 'off') {
|
||||
patchText(versionSub, `已关闭更新提醒 (${modeTag})`);
|
||||
patchClasses(versionSub, { 'accent-ok': false });
|
||||
patchText(updatePluginBtnText, cs.updateAvailable ? `手动升级 v${latVer}` : '检查更新');
|
||||
patchClasses(updatePluginBtn, { 'btn-primary': false, 'btn-secondary': true });
|
||||
} else {
|
||||
patchText(versionSub, `已是最新 (${modeTag})`);
|
||||
patchClasses(versionSub, { 'accent-ok': false });
|
||||
|
||||
@@ -119,8 +119,8 @@ export const StepsDetailView = defineComponent({
|
||||
style: 'flex: 1; min-height: 0; display: flex; flex-direction: column;',
|
||||
},
|
||||
[
|
||||
h('div', { className: 'panel-header' }, [
|
||||
h('span', { className: 'panel-title' }, [
|
||||
h('div', { className: 'panel-header steps-panel-header' }, [
|
||||
h('span', { className: 'panel-title steps-panel-title' }, [
|
||||
createSvgIcon('table', { size: 13 }),
|
||||
h('span', { text: '调用记录' }),
|
||||
]),
|
||||
@@ -349,7 +349,7 @@ export const StepsDetailView = defineComponent({
|
||||
patchText(refs.speedMain, formatMetric(m.avgTokPerSec, ' tok/s'));
|
||||
patchText(refs.speedSub, `有效 ${sampleSummary(m.speedSummary)}`);
|
||||
patchText(refs.tdTokens, formatTokens(m.totalTokens || 0));
|
||||
patchText(refs.tdCost, formatUsd(m.costUsd, { unpricedCalls: m.unpricedCalls }));
|
||||
patchText(refs.tdCost, formatUsd(m.costUsd || 0));
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
+130
-12
@@ -280,6 +280,8 @@ input {
|
||||
.steps-inline-scope-select .select-menu {
|
||||
left: auto;
|
||||
right: 0;
|
||||
min-width: 220px;
|
||||
max-width: min(320px, 82vw);
|
||||
}
|
||||
|
||||
.session-left {
|
||||
@@ -2236,21 +2238,40 @@ input {
|
||||
background: var(--surface-hover);
|
||||
}
|
||||
|
||||
.steps-panel-header {
|
||||
flex-wrap: wrap;
|
||||
row-gap: 6px;
|
||||
}
|
||||
|
||||
.steps-panel-title {
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
.steps-header-controls {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 6px;
|
||||
flex-wrap: wrap;
|
||||
flex: 1 1 280px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.steps-header-controls .segmented {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.steps-inline-scope-select {
|
||||
flex: 1 1 120px;
|
||||
min-width: 120px;
|
||||
flex: 0 1 180px;
|
||||
min-width: 72px;
|
||||
max-width: 190px;
|
||||
}
|
||||
|
||||
.steps-inline-scope-select .select-trigger {
|
||||
height: 22px;
|
||||
padding: 0 6px;
|
||||
gap: 4px;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
font-size: 11px;
|
||||
border: 1px solid var(--border-hairline);
|
||||
background: var(--surface-subtle);
|
||||
@@ -2337,6 +2358,7 @@ input {
|
||||
}
|
||||
|
||||
.wm-multi-btn[hidden],
|
||||
.wm-update-btn[hidden],
|
||||
.wm-cap-slot[hidden],
|
||||
.wm-sep[hidden] {
|
||||
display: none !important;
|
||||
@@ -2558,7 +2580,7 @@ input {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
/* 右上角绝对定位更新圆点,不参与文档流,零宽度抖动 */
|
||||
/* 仅在超窄 ring-only 折叠态下使用右上角 5px 提示圆点;常规态由柔和微胶囊 .wm-update-btn 承载 */
|
||||
.wm-update-dot {
|
||||
position: absolute;
|
||||
top: 3px;
|
||||
@@ -2566,10 +2588,83 @@ input {
|
||||
width: 5px;
|
||||
height: 5px;
|
||||
border-radius: var(--radius-pill);
|
||||
background: var(--metric-ok);
|
||||
background: var(--accent-primary);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
:host(.wm-capsule-host:not([data-layout="ring-only"])) .wm-update-dot {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
/* 顶栏右侧柔和半透明新版本胶囊按钮(20px 矮胶囊嵌套于 28px 顶栏,克制不突兀,左键一键升级) */
|
||||
.wm-update-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 3px;
|
||||
height: 20px;
|
||||
padding: 0 6px 0 5px;
|
||||
margin: 0;
|
||||
background: color-mix(in srgb, var(--accent-primary) 10%, transparent);
|
||||
color: var(--accent-primary);
|
||||
border: 1px solid color-mix(in srgb, var(--accent-primary) 24%, transparent);
|
||||
border-radius: var(--radius-pill);
|
||||
font-family: inherit;
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
line-height: 18px;
|
||||
letter-spacing: 0.01em;
|
||||
font-variant-numeric: tabular-nums;
|
||||
white-space: nowrap;
|
||||
flex-shrink: 0;
|
||||
cursor: pointer;
|
||||
-webkit-app-region: no-drag;
|
||||
transition:
|
||||
background-color var(--dur-instant) var(--ease-fast),
|
||||
border-color var(--dur-instant) var(--ease-fast),
|
||||
transform var(--dur-instant) var(--ease-fast);
|
||||
}
|
||||
|
||||
.wm-update-btn:hover:not(:disabled) {
|
||||
background: color-mix(in srgb, var(--accent-primary) 18%, transparent);
|
||||
border-color: color-mix(in srgb, var(--accent-primary) 40%, transparent);
|
||||
}
|
||||
|
||||
.wm-update-btn:active:not(:disabled) {
|
||||
transform: scale(0.96);
|
||||
}
|
||||
|
||||
.wm-update-btn:disabled {
|
||||
opacity: 0.72;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
@keyframes wm-spin-icon {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
.wm-update-btn.is-updating .svg-icon {
|
||||
animation: wm-spin-icon 0.9s linear infinite;
|
||||
}
|
||||
|
||||
:host(.wm-capsule-host[data-layout="minimal"]) .wm-update-label {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
:host(.wm-capsule-host[data-layout="minimal"]) .wm-update-btn {
|
||||
width: 20px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
:host(.wm-capsule-host[data-layout="ring-only"]) .wm-update-btn {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
/* 四级响应式迟滞折叠(基于可见槽位次序 data-vis-rank 与分隔线次序 data-sep-for-rank 动态折叠) */
|
||||
:host(.wm-capsule-host[data-layout="compact"]) .wm-cap-slot[data-vis-rank="3"],
|
||||
:host(.wm-capsule-host[data-layout="compact"]) .wm-sep[data-sep-for-rank="3"] {
|
||||
@@ -2730,6 +2825,36 @@ input {
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.wm-hover-update-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: var(--space-2);
|
||||
padding: 5px 10px;
|
||||
border-radius: var(--radius-xs);
|
||||
background: var(--accent-primary-soft);
|
||||
border: 1px solid var(--accent-primary-border);
|
||||
font-size: 11.5px;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.wm-hover-update-left {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
color: var(--accent-primary);
|
||||
font-weight: 600;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.wm-hover-update-hint {
|
||||
color: var(--text-secondary);
|
||||
font-size: 11px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.wm-hover-quota-pools {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -2839,10 +2964,3 @@ input {
|
||||
background: color-mix(in srgb, var(--text-secondary) 38%, transparent);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.wm-multi-empty-hint {
|
||||
font-size: 11px;
|
||||
color: var(--text-muted);
|
||||
white-space: nowrap;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
@@ -69,6 +69,58 @@ test('BUG-01 & INCON-01: Google-proxied Claude/GPT/o-series never misclassify as
|
||||
|
||||
const m20 = h.resolveModelInfo('MODEL_PLACEHOLDER_M20', new Map(), 'API_PROVIDER_GOOGLE_GEMINI');
|
||||
assert.equal(m20.modelId, 'gemini-3.5-flash');
|
||||
|
||||
// Gemini Hydrogen (3.8 Flash pricing) & Helix (3.5 Flash Lite pricing), shared Gemini pool
|
||||
const dynHydrogenMap = new Map([
|
||||
['MODEL_PLACEHOLDER_M480', { modelId: '', label: 'Gemini 4 Hydrogen (High)' }],
|
||||
['MODEL_PLACEHOLDER_M481', { modelId: '', label: 'Gemini 4 Hydrogen (Low)' }],
|
||||
['MODEL_PLACEHOLDER_M482', { modelId: '', label: 'Gemini 4 Helix' }],
|
||||
]);
|
||||
const hydroHigh = h.resolveModelInfo('MODEL_PLACEHOLDER_M480', dynHydrogenMap);
|
||||
assert.equal(hydroHigh.family, 'Gemini');
|
||||
assert.equal(hydroHigh.shortName, 'hydrogen-4-high');
|
||||
assert.deepEqual(
|
||||
{ i: hydroHigh.pricing?.input, c: hydroHigh.pricing?.cache, o: hydroHigh.pricing?.output },
|
||||
{ i: 0.75, c: 0.075, o: 3.75 }
|
||||
);
|
||||
const hydroLow = h.resolveModelInfo('MODEL_PLACEHOLDER_M481', dynHydrogenMap);
|
||||
assert.equal(hydroLow.shortName, 'hydrogen-4-low');
|
||||
assert.deepEqual(
|
||||
{ i: hydroLow.pricing?.input, c: hydroLow.pricing?.cache, o: hydroLow.pricing?.output },
|
||||
{ i: 0.3, c: 0.03, o: 2.5 }
|
||||
);
|
||||
const hydroCodename = h.resolveModelInfo('gemini-hydrogen');
|
||||
assert.equal(hydroCodename.family, 'Gemini');
|
||||
assert.equal(hydroCodename.label, 'Gemini Hydrogen');
|
||||
assert.equal(hydroCodename.pricing?.input, 0.75);
|
||||
|
||||
const helixInfo = h.resolveModelInfo('MODEL_PLACEHOLDER_M482', dynHydrogenMap);
|
||||
assert.equal(helixInfo.family, 'Gemini');
|
||||
assert.equal(helixInfo.shortName, 'helix-4');
|
||||
assert.deepEqual(
|
||||
{ i: helixInfo.pricing?.input, c: helixInfo.pricing?.cache, o: helixInfo.pricing?.output },
|
||||
{ i: 0.3, c: 0.03, o: 2.5 }
|
||||
);
|
||||
const helixCodename = h.resolveModelInfo('gemini-helix');
|
||||
assert.equal(helixCodename.family, 'Gemini');
|
||||
assert.equal(helixCodename.label, 'Gemini Helix');
|
||||
assert.equal(helixCodename.pricing?.output, 2.5);
|
||||
|
||||
const { quotaPoolsMap } = h.buildOfficialQuotaPools(null, [
|
||||
{
|
||||
modelOrAlias: { model: 'MODEL_PLACEHOLDER_M480' },
|
||||
label: 'Gemini 4 Hydrogen (High)',
|
||||
quotaInfo: { remainingFraction: 0.8, resetTime: new Date(nowMs + 3600_000).toISOString() },
|
||||
},
|
||||
{
|
||||
modelOrAlias: { model: 'MODEL_PLACEHOLDER_M482' },
|
||||
label: 'Gemini 4 Helix',
|
||||
quotaInfo: { remainingFraction: 0.8, resetTime: new Date(nowMs + 3600_000).toISOString() },
|
||||
},
|
||||
]);
|
||||
assert.equal(quotaPoolsMap.has('Hydrogen'), false, 'Hydrogen has no dedicated quota pool');
|
||||
assert.equal(quotaPoolsMap.has('Helix'), false, 'Helix has no dedicated quota pool');
|
||||
assert.equal(quotaPoolsMap.get('Gemini')?.isAvailable, true);
|
||||
});
|
||||
|
||||
test('BUG-02 & BUG-11: ide:<uuid> external sessions do not double-count live conversations, cross-account entries are isolated, and orphan subagents never leak to top-level list', async () => {
|
||||
@@ -261,7 +313,7 @@ test('BUG-09, BUG-14 & BUG-15: SemVer 2.0 prerelease/build ordering, future-only
|
||||
assert.equal(formatCountdown(new Date(nowMs + 30_000).toISOString(), nowMs), '<1分钟后重置');
|
||||
assert.equal(formatCountdown('1969-12-31T23:59:59Z', nowMs), '未知重置时间');
|
||||
assert.equal(formatUsd(0.0004, { precise: true }), '<$0.001');
|
||||
assert.equal(formatUsd(12.34, { unpricedCalls: 1, compactPending: true }), '$12.34+');
|
||||
assert.equal(formatUsd(12.34, { unpricedCalls: 1, compactPending: true }), '$12.34');
|
||||
assert.equal(speedReasonText('short_timing'), '耗时过短 (<0.5s)');
|
||||
});
|
||||
|
||||
|
||||
@@ -144,6 +144,6 @@ export function backendHarness({
|
||||
return {ok:true,json:async()=>data};
|
||||
},
|
||||
};
|
||||
vm.runInNewContext(source+'\n globalThis.api={buildTelemetryPayloadInternal,computeStepCost,resolveModelInfo,inferFamilyFromProviderOrKey,isCarbonModelIdentifier,PLACEHOLDER_MAP,normalizeQuotaFraction,classifyOfficialBucketWindow,classifyQuotaPoolIdentity,buildOfficialQuotaPools,resolveTimeWindow,sanitizeCatalogPayload,rebuildActiveCatalog,syncCloudCatalog,getCloudStatus,isValidSemver,compareSemver,performPluginUpdate};',ctx);
|
||||
vm.runInNewContext(source+'\n globalThis.api={buildTelemetryPayloadInternal,computeStepCost,resolveModelInfo,inferFamilyFromProviderOrKey,isCarbonModelIdentifier,PLACEHOLDER_MAP,normalizeQuotaFraction,classifyOfficialBucketWindow,classifyQuotaPoolIdentity,buildOfficialQuotaPools,resolveTimeWindow,sanitizeCatalogPayload,rebuildActiveCatalog,syncCloudCatalog,getCloudStatus,isValidSemver,compareSemver,performPluginUpdate,loadSettings,executeSettingsAction};',ctx);
|
||||
return {...ctx.api,state};
|
||||
}
|
||||
|
||||
@@ -275,3 +275,57 @@ test('performPluginUpdate pulls fast-forward when git worktree is clean, on main
|
||||
assert.equal(res.currentVersion, '1.4.0');
|
||||
assert.equal(gitCalls.length, 6); // status, rev-parse, fetch, show, merge-base, pull
|
||||
});
|
||||
|
||||
test('pluginUpdateMode supports manual (default), auto, and off with legacy autoUpdatePlugin compatibility', async () => {
|
||||
const defaultH = backendHarness();
|
||||
assert.equal(defaultH.loadSettings().pluginUpdateMode, 'manual');
|
||||
assert.equal(defaultH.loadSettings().autoUpdatePlugin, false);
|
||||
|
||||
const legacyAutoH = backendHarness({ settings: { autoUpdatePlugin: true } });
|
||||
assert.equal(legacyAutoH.loadSettings().pluginUpdateMode, 'auto');
|
||||
assert.equal(legacyAutoH.loadSettings().autoUpdatePlugin, true);
|
||||
|
||||
const offSettings = {};
|
||||
let gitTriggered = false;
|
||||
const offH = backendHarness({
|
||||
settings: offSettings,
|
||||
hasGitDir: true,
|
||||
pluginRootPath: '/Users/test/.gemini/config/plugins/usage-monitor',
|
||||
pluginManifest: { name: 'usage-monitor', version: '1.4.0' },
|
||||
remoteFetch: async () => ({
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
schemaVersion: 1,
|
||||
catalogVersion: '2026.11.11.9',
|
||||
updatedAt: '2026-11-11T22:00:00+09:00',
|
||||
latestPluginVersion: '1.5.0',
|
||||
pricing: {
|
||||
'gemini-4-argon': { input: 2.0, cache: 0.1, output: 10.0, short: 'argon-4', family: 'Gemini' },
|
||||
},
|
||||
}),
|
||||
}),
|
||||
execFileImpl: (_cmd, _args, opts, cb) => {
|
||||
gitTriggered = true;
|
||||
const fn = typeof opts === 'function' ? opts : cb;
|
||||
fn(null, '', '');
|
||||
},
|
||||
});
|
||||
|
||||
const saveOff = offH.executeSettingsAction({ pluginUpdateMode: 'off' }).updated;
|
||||
assert.equal(saveOff.pluginUpdateMode, 'off');
|
||||
assert.equal(saveOff.autoUpdatePlugin, false);
|
||||
Object.assign(offSettings, saveOff);
|
||||
|
||||
await offH.syncCloudCatalog({ force: true });
|
||||
await new Promise((r) => setTimeout(r, 20));
|
||||
assert.equal(gitTriggered, false, 'pluginUpdateMode=off must never trigger auto update');
|
||||
|
||||
const saveAuto = offH.executeSettingsAction({ pluginUpdateMode: 'auto' }).updated;
|
||||
assert.equal(saveAuto.pluginUpdateMode, 'auto');
|
||||
assert.equal(saveAuto.autoUpdatePlugin, true);
|
||||
Object.assign(offSettings, saveAuto);
|
||||
|
||||
await offH.syncCloudCatalog({ force: true });
|
||||
await new Promise((r) => setTimeout(r, 20));
|
||||
assert.equal(gitTriggered, true, 'pluginUpdateMode=auto triggers background update check');
|
||||
});
|
||||
|
||||
@@ -177,9 +177,9 @@ test('empty session does not invent an Argon model or a model quota pool', async
|
||||
assert.equal(p.quotas.activePool.isAvailable,false); assert.equal(p.quotas.activePool.family,'Unknown');
|
||||
});
|
||||
|
||||
test('unknown cost renders as pending, known subtotals disclose missing calls', () => {
|
||||
test('unknown single-step cost renders as pending while aggregate subtotals omit pending suffix', () => {
|
||||
assert.equal(formatUsd(null),'待定'); assert.equal(formatUsd(0),'$0.00');
|
||||
assert.equal(formatUsd(0.1,{unpricedCalls:1}),'$0.10 + 待定');
|
||||
assert.equal(formatUsd(0.1,{unpricedCalls:1}),'$0.10');
|
||||
});
|
||||
|
||||
test('custom cost budget cannot claim a complete remaining percentage when prices are missing', async () => {
|
||||
|
||||
@@ -817,8 +817,8 @@ test('Compiled app.js mounts dual Shadow DOM hosts, tracks /c/<uuid> routes, pro
|
||||
},
|
||||
consumption: {
|
||||
selectedRange: { key: 'today', label: '今天', startMs: 1, endMs: 2 },
|
||||
session: { totalTokens: 128000, costUsd: 0.42 },
|
||||
account: { totalTokens: 500000, costUsd: 1.5 },
|
||||
session: { totalTokens: 128000, costUsd: 0.42, unpricedCalls: 12 },
|
||||
account: { totalTokens: 500000, costUsd: 1.5, unpricedCalls: 3993 },
|
||||
trendSeries: [],
|
||||
monthlySeries: [],
|
||||
},
|
||||
@@ -949,7 +949,16 @@ test('Compiled app.js mounts dual Shadow DOM hosts, tracks /c/<uuid> routes, pro
|
||||
|
||||
// Verify hovering right capsule closes unpinned multi-session panel and opens rich 3-card hover overview HUD (.wm-hover-tip)
|
||||
assert.ok(hoverTipEl, 'Hover overview HUD mounted in portal shadow root');
|
||||
assert.equal(hoverTipEl.children.length, 3, 'Hover HUD has 3 signature cards (matrix + context + quotas)');
|
||||
assert.equal(
|
||||
hoverTipEl.children.length,
|
||||
4,
|
||||
'Hover HUD has optional update banner + 3 signature cards (matrix + context + quotas)'
|
||||
);
|
||||
assert.equal(
|
||||
multiPanelEl.querySelector('.wm-multi-empty-hint'),
|
||||
null,
|
||||
'Redundant hover/pin hint copy removed from multi-session empty state'
|
||||
);
|
||||
|
||||
capsuleBtn.dispatchEvent({ type: 'mouseenter', clientX: 960, clientY: 18 });
|
||||
assert.equal(ov.isMultiOpen(), false, 'Mutual exclusion closes unpinned multi-session panel');
|
||||
@@ -1126,6 +1135,81 @@ test('Compiled app.js mounts dual Shadow DOM hosts, tracks /c/<uuid> routes, pro
|
||||
assert.equal(capSlots[0].children.length, 2, 'Ring SVG re-attached on Slot 0');
|
||||
assert.equal(capSlots[0].querySelector('.wm-ctx-pct').textContent, '50%');
|
||||
|
||||
// Verify 3-tier update mode select (manual default -> off hides topbar/hover prompts -> auto -> manual)
|
||||
const topbarUpdateBtn = capsuleHost.shadowRoot.querySelector('.wm-update-btn');
|
||||
const hoverUpdateBar = hoverTipEl.querySelector('.wm-hover-update-bar');
|
||||
const headerUpdateBtn = popoverEl.querySelector('.update-badge-btn');
|
||||
assert.ok(topbarUpdateBtn, 'Topbar subtle update pill button mounted');
|
||||
assert.ok(hoverUpdateBar, 'Hover card update banner mounted');
|
||||
assert.equal(topbarUpdateBtn.hasAttribute('hidden'), false, 'Update pill visible in default manual mode');
|
||||
assert.equal(topbarUpdateBtn.querySelector('.wm-update-label').textContent, 'v1.5.0');
|
||||
assert.ok(
|
||||
topbarUpdateBtn.children[0].children[0].getAttribute('d').includes('13.2l3.8-3.8'),
|
||||
'Topbar update pill uses downward arrow matching panel & settings design language'
|
||||
);
|
||||
assert.equal(hoverUpdateBar.hasAttribute('hidden'), false, 'Hover update bar visible in default manual mode');
|
||||
assert.ok(
|
||||
hoverUpdateBar
|
||||
.querySelector('.wm-hover-update-left')
|
||||
.children[0].children[0].getAttribute('d')
|
||||
.includes('13.2l3.8-3.8'),
|
||||
'Hover update bar uses downward arrow matching panel & settings design language'
|
||||
);
|
||||
assert.equal(
|
||||
hoverUpdateBar.querySelector('.wm-hover-update-left').children[1].textContent,
|
||||
'发现新版本 v1.5.0'
|
||||
);
|
||||
assert.equal(
|
||||
hoverUpdateBar.querySelector('.wm-hover-update-hint').textContent,
|
||||
'点击顶栏 v1.5.0 即可更新'
|
||||
);
|
||||
assert.equal(headerUpdateBtn.hasAttribute('hidden'), false);
|
||||
|
||||
const updateModeSelectEl = settingsSelects[5];
|
||||
assert.equal(updateModeSelectEl.querySelector('.select-label').textContent, '仅提示新版本,手动更新');
|
||||
updateModeSelectEl.querySelector('.select-trigger').dispatchEvent({ type: 'click', stopPropagation() {} });
|
||||
const updateOpts = updateModeSelectEl.querySelectorAll('.select-option');
|
||||
assert.equal(updateOpts.length, 3, '3 update modes rendered (manual, auto, off)');
|
||||
assert.equal(updateOpts[0].querySelector('.select-option-text').textContent, '仅提示新版本,手动更新');
|
||||
assert.equal(updateOpts[1].querySelector('.select-option-text').textContent, '自动更新');
|
||||
assert.equal(updateOpts[2].querySelector('.select-option-text').textContent, '关闭更新');
|
||||
|
||||
updateOpts[2].dispatchEvent({ type: 'click', stopPropagation() {} });
|
||||
await new Promise((r) => setTimeout(r, 30));
|
||||
assert.equal(mockSettings.pluginUpdateMode, 'off');
|
||||
assert.equal(mockSettings.autoUpdatePlugin, false);
|
||||
assert.equal(topbarUpdateBtn.hasAttribute('hidden'), true, 'Topbar update pill hidden when mode=off');
|
||||
assert.equal(hoverUpdateBar.hasAttribute('hidden'), true, 'Hover update bar hidden when mode=off');
|
||||
assert.equal(headerUpdateBtn.hasAttribute('hidden'), true, 'Header update button hidden when mode=off');
|
||||
|
||||
updateModeSelectEl.querySelector('.select-trigger').dispatchEvent({ type: 'click', stopPropagation() {} });
|
||||
updateModeSelectEl.querySelectorAll('.select-option')[1].dispatchEvent({ type: 'click', stopPropagation() {} });
|
||||
await new Promise((r) => setTimeout(r, 30));
|
||||
assert.equal(mockSettings.pluginUpdateMode, 'auto');
|
||||
assert.equal(mockSettings.autoUpdatePlugin, true);
|
||||
assert.equal(topbarUpdateBtn.hasAttribute('hidden'), false, 'Topbar update pill restored when mode=auto');
|
||||
|
||||
updateModeSelectEl.querySelector('.select-trigger').dispatchEvent({ type: 'click', stopPropagation() {} });
|
||||
updateModeSelectEl.querySelectorAll('.select-option')[0].dispatchEvent({ type: 'click', stopPropagation() {} });
|
||||
await new Promise((r) => setTimeout(r, 260));
|
||||
assert.equal(mockSettings.pluginUpdateMode, 'manual');
|
||||
assert.equal(mockSettings.autoUpdatePlugin, false);
|
||||
assert.equal(topbarUpdateBtn.hasAttribute('hidden'), false, 'Topbar update pill visible when mode=manual');
|
||||
|
||||
// Verify ConsumptionView omits "+ 待定" / "3993 步费用待定" and StepsDetailView protects header title
|
||||
pillTabs[1].dispatchEvent({ type: 'click', stopPropagation() {} });
|
||||
await new Promise((r) => setTimeout(r, 15));
|
||||
const heroCostEl = popoverEl.querySelector('.cons-hero-cost');
|
||||
assert.equal(heroCostEl.textContent, '$1.50', 'Consumption hero cost omits + 待定');
|
||||
const heroCostBaseline = heroCostEl.parentElement;
|
||||
assert.equal(
|
||||
heroCostBaseline.children[1].textContent,
|
||||
'≈ ¥11',
|
||||
'Consumption sub-label renders CNY approx instead of 步费用待定'
|
||||
);
|
||||
assert.ok(popoverEl.querySelector('.steps-panel-header'), 'Steps header flex wrapper present');
|
||||
assert.ok(popoverEl.querySelector('.steps-panel-title'), 'Steps title non-shrinking class present');
|
||||
|
||||
// Verify bundle version bump NEVER calls window.location.reload() in overlay mode
|
||||
currentBundleVer = 'ver-200';
|
||||
mockLocation.pathname = '/c/cccccccc-4444-5555-6666-dddddddddddd';
|
||||
|
||||
Reference in New Issue
Block a user