mirror of
https://github.com/lWolvesl/antigravity-usage-monitor.git
synced 2026-11-26 17:09:28 +08:00
feat(panel): 3-tier update modes, topbar update prompt, and Gemini Hydrogen & Helix support (v1.4.4)
This commit is contained in:
@@ -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));
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user