mirror of
https://github.com/lWolvesl/antigravity-usage-monitor.git
synced 2026-11-27 01:19:25 +08:00
feat(panel): refine quota reservation estimator, tier 5x/20x badge, conditional argon_weekly slot, and chart markers
This commit is contained in:
@@ -1311,16 +1311,15 @@ export function createSessionLineChart() {
|
||||
patchStyleVar(mLine, '--sstep-fit-accent', seriesColor);
|
||||
multiLineGroup.appendChild(mLine);
|
||||
|
||||
if (seriesPts.length <= 36) {
|
||||
for (const pt of seriesPts) {
|
||||
const dot = document.createElementNS(SVG_NS, 'circle');
|
||||
dot.setAttribute('cx', pt.x.toFixed(1));
|
||||
dot.setAttribute('cy', pt.y.toFixed(1));
|
||||
dot.setAttribute('r', seriesPts.length > 20 ? '1.7' : '2.1');
|
||||
dot.setAttribute('class', 'sstep-node-dot');
|
||||
patchStyleVar(dot, '--dot-stroke', seriesColor);
|
||||
dotsGroup.appendChild(dot);
|
||||
}
|
||||
if (seriesPts.length === 1) {
|
||||
const pt = seriesPts[0];
|
||||
const dot = document.createElementNS(SVG_NS, 'circle');
|
||||
dot.setAttribute('cx', pt.x.toFixed(1));
|
||||
dot.setAttribute('cy', pt.y.toFixed(1));
|
||||
dot.setAttribute('r', '2.1');
|
||||
dot.setAttribute('class', 'sstep-node-dot');
|
||||
patchStyleVar(dot, '--dot-stroke', seriesColor);
|
||||
dotsGroup.appendChild(dot);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1344,40 +1343,30 @@ export function createSessionLineChart() {
|
||||
patchAttr(linePath, 'd', lineD);
|
||||
patchAttr(areaPath, 'd', `${lineD} L ${lastX} ${BOTTOM_Y} L ${firstX} ${BOTTOM_Y} Z`);
|
||||
}
|
||||
|
||||
if (points.length <= 64) {
|
||||
for (const pt of points) {
|
||||
const dot = document.createElementNS(SVG_NS, 'circle');
|
||||
dot.setAttribute('cx', pt.x.toFixed(1));
|
||||
dot.setAttribute('cy', pt.y.toFixed(1));
|
||||
if (pt.valid) {
|
||||
dot.setAttribute('r', points.length > 36 ? '1.8' : '2.3');
|
||||
dot.setAttribute('class', 'sstep-node-dot');
|
||||
patchStyleVar(
|
||||
dot,
|
||||
'--dot-stroke',
|
||||
modelColorMap.size > 1 ? pt.dotColor : accentColor
|
||||
);
|
||||
} else {
|
||||
dot.setAttribute('r', '1.6');
|
||||
dot.setAttribute('class', 'sstep-node-dot is-skipped');
|
||||
}
|
||||
dotsGroup.appendChild(dot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const anomalyTicks = [];
|
||||
for (const pt of points) {
|
||||
if (!pt.valid || !pt.anomalySummary) continue;
|
||||
const aDot = document.createElementNS(SVG_NS, 'circle');
|
||||
aDot.setAttribute('cx', pt.x.toFixed(1));
|
||||
aDot.setAttribute('cy', pt.y.toFixed(1));
|
||||
aDot.setAttribute('r', '2.9');
|
||||
aDot.setAttribute(
|
||||
anomalyTicks.push(pt);
|
||||
}
|
||||
anomalyTicks.sort((a, b) =>
|
||||
a.anomalySeverity === 'danger' ? 1 : b.anomalySeverity === 'danger' ? -1 : 0
|
||||
);
|
||||
const tickTopY = (BOTTOM_Y - 5).toFixed(1);
|
||||
const tickBotY = BOTTOM_Y.toFixed(1);
|
||||
for (const pt of anomalyTicks) {
|
||||
const xStr = pt.x.toFixed(1);
|
||||
const aTick = document.createElementNS(SVG_NS, 'line');
|
||||
aTick.setAttribute('x1', xStr);
|
||||
aTick.setAttribute('x2', xStr);
|
||||
aTick.setAttribute('y1', tickTopY);
|
||||
aTick.setAttribute('y2', tickBotY);
|
||||
aTick.setAttribute(
|
||||
'class',
|
||||
`sstep-anomaly-dot${pt.anomalySeverity === 'danger' ? ' is-danger' : ''}`
|
||||
`sstep-anomaly-dot sstep-anomaly-tick${pt.anomalySeverity === 'danger' ? ' is-danger' : ''}`
|
||||
);
|
||||
anomalyDotsGroup.appendChild(aDot);
|
||||
anomalyDotsGroup.appendChild(aTick);
|
||||
}
|
||||
|
||||
const tickIndices = computeStepTickIndices(points.length);
|
||||
@@ -2288,11 +2277,14 @@ export function createModelFitChart() {
|
||||
multiCurveGroup.appendChild(curveEl);
|
||||
}
|
||||
}
|
||||
anomalyOverlayDots.sort((a, b) =>
|
||||
a.anomalySeverity === 'danger' ? 1 : b.anomalySeverity === 'danger' ? -1 : 0
|
||||
);
|
||||
for (const sp of anomalyOverlayDots) {
|
||||
const aDot = document.createElementNS(SVG_NS, 'circle');
|
||||
aDot.setAttribute('cx', sp.x.toFixed(1));
|
||||
aDot.setAttribute('cy', sp.rawY.toFixed(1));
|
||||
aDot.setAttribute('r', '2.9');
|
||||
aDot.setAttribute('r', dotRadius);
|
||||
aDot.setAttribute(
|
||||
'class',
|
||||
`sstep-scatter-dot is-anomaly${sp.anomalySeverity === 'danger' ? ' is-danger' : ''}`
|
||||
@@ -2462,11 +2454,14 @@ export function createModelFitChart() {
|
||||
dot.setAttribute('class', 'sstep-scatter-dot');
|
||||
scatterTarget.appendChild(dot);
|
||||
}
|
||||
singleAnomalyDots.sort((a, b) =>
|
||||
a.anomalySeverity === 'danger' ? 1 : b.anomalySeverity === 'danger' ? -1 : 0
|
||||
);
|
||||
for (const s of singleAnomalyDots) {
|
||||
const aDot = document.createElementNS(SVG_NS, 'circle');
|
||||
aDot.setAttribute('cx', s.x.toFixed(1));
|
||||
aDot.setAttribute('cy', s.rawY.toFixed(1));
|
||||
aDot.setAttribute('r', '2.9');
|
||||
aDot.setAttribute('r', dotRadius);
|
||||
aDot.setAttribute(
|
||||
'class',
|
||||
`sstep-scatter-dot is-anomaly${s.anomalySeverity === 'danger' ? ' is-danger' : ''}`
|
||||
|
||||
@@ -281,16 +281,7 @@ export function createTrendAreaChart({ onSelectSlot = null } = {}) {
|
||||
linePath.setAttribute('fill', 'none');
|
||||
svg.appendChild(linePath);
|
||||
|
||||
const dotsGroup = document.createElementNS(SVG_NS, 'g');
|
||||
dotsGroup.setAttribute('class', 'trend-dots-group');
|
||||
svg.appendChild(dotsGroup);
|
||||
|
||||
const peakDot = document.createElementNS(SVG_NS, 'circle');
|
||||
peakDot.setAttribute('r', '3');
|
||||
peakDot.setAttribute('class', 'trend-peak-dot');
|
||||
svg.appendChild(peakDot);
|
||||
|
||||
// 悬停十字准星与焦点圆点
|
||||
// 悬停十字准星及焦点圆点
|
||||
const hoverLine = document.createElementNS(SVG_NS, 'line');
|
||||
hoverLine.setAttribute('class', 'trend-hover-line');
|
||||
hoverLine.setAttribute('y1', '12');
|
||||
@@ -1129,25 +1120,9 @@ export function createTrendAreaChart({ onSelectSlot = null } = {}) {
|
||||
xAxisEl.appendChild(tickEl);
|
||||
tickElsByIdx.set(tIdx, tickEl);
|
||||
}
|
||||
|
||||
// 渲染采样点小圆点(当点数 <= 36 时展示,突出有消耗的整点/日期)
|
||||
while (dotsGroup.firstChild) dotsGroup.removeChild(dotsGroup.firstChild);
|
||||
if (pts.length <= 36) {
|
||||
for (let i = 0; i < pts.length; i++) {
|
||||
if (pts[i].tokens <= 0) continue;
|
||||
const dot = document.createElementNS(SVG_NS, 'circle');
|
||||
dot.setAttribute('cx', pts[i].x.toFixed(1));
|
||||
dot.setAttribute('cy', pts[i].y.toFixed(1));
|
||||
dot.setAttribute('r', '2');
|
||||
dot.setAttribute('class', 'trend-node-dot');
|
||||
dotsGroup.appendChild(dot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const peakPt = pts[peakIdx] || { x: viewW / 2, y: BOTTOM_Y };
|
||||
patchAttr(peakDot, 'cx', peakPt.x.toFixed(1));
|
||||
patchAttr(peakDot, 'cy', peakPt.y.toFixed(1));
|
||||
|
||||
const peakSlot = slots[peakIdx];
|
||||
const peakText =
|
||||
|
||||
@@ -7,7 +7,11 @@
|
||||
|
||||
import { t } from '../../i18n/index.js';
|
||||
|
||||
export function buildStructurePreviewTelemetry(baseSettings = {}, draftOverrides = {}) {
|
||||
export function buildStructurePreviewTelemetry(
|
||||
baseSettings = {},
|
||||
draftOverrides = {},
|
||||
{ includeArgonPool = false } = {}
|
||||
) {
|
||||
const anchorMinMs = Math.floor(Date.now() / 60000) * 60000;
|
||||
const reset5hIso = new Date(anchorMinMs + (2 * 60 + 42) * 60000).toISOString();
|
||||
const resetWkIso = new Date(anchorMinMs + (4 * 24 * 60 + 180) * 60000).toISOString();
|
||||
@@ -361,8 +365,10 @@ export function buildStructurePreviewTelemetry(baseSettings = {}, draftOverrides
|
||||
return {
|
||||
settings: mergedSettings,
|
||||
account: {
|
||||
tierId: 'g1-ultra-lite-tier',
|
||||
tierName: 'Google AI Ultra',
|
||||
planName: 'Pro',
|
||||
tierMultiplier: '5x',
|
||||
planName: '5x',
|
||||
aiCredits: 0,
|
||||
},
|
||||
quotas: {
|
||||
@@ -400,6 +406,21 @@ export function buildStructurePreviewTelemetry(baseSettings = {}, draftOverrides
|
||||
cycle5h: { tokens: 1754800, costUsd: 1.28, calls: 24 },
|
||||
cycleWeekly: { tokens: 14200000, costUsd: 11.4, calls: 186 },
|
||||
},
|
||||
...(includeArgonPool
|
||||
? [
|
||||
{
|
||||
poolKey: 'Argon',
|
||||
poolLabel: 'Gemini 4 Argon',
|
||||
family: 'Argon',
|
||||
has5h: false,
|
||||
hasWeekly: true,
|
||||
weeklyUsedPct: 58,
|
||||
weeklyRemainingPct: 42,
|
||||
weeklyResetTime: resetWkIso,
|
||||
cycleWeekly: { tokens: 4200000, costUsd: 6.4, calls: 48 },
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{
|
||||
poolKey: 'Claude & GPT',
|
||||
poolLabel: 'Claude & GPT',
|
||||
|
||||
@@ -210,7 +210,7 @@ function syncQuotaWindowMeter({
|
||||
const rsvWidth = +Math.min(Math.max(0, 100 - actualWidth), rsvVal).toFixed(2);
|
||||
patchStyleVar(fillEl, '--fill-w', `${actualWidth}%`);
|
||||
patchStyleVar(fillReservedEl, '--reserved-w', `${rsvWidth}%`);
|
||||
patchClasses(fillReservedEl, { 'is-active': true });
|
||||
patchClasses(fillReservedEl, { 'is-active': true, 'has-sep': actualWidth > 0 });
|
||||
} else {
|
||||
patchText(
|
||||
metaBeforeEl,
|
||||
@@ -230,7 +230,7 @@ function syncQuotaWindowMeter({
|
||||
patchAttr(trackEl, 'title', null);
|
||||
patchStyleVar(fillEl, '--fill-w', `${Math.min(100, usedVal)}%`);
|
||||
patchStyleVar(fillReservedEl, '--reserved-w', '0%');
|
||||
patchClasses(fillReservedEl, { 'is-active': false });
|
||||
patchClasses(fillReservedEl, { 'is-active': false, 'has-sep': false });
|
||||
}
|
||||
|
||||
patchClasses(fillEl, {
|
||||
@@ -370,6 +370,45 @@ export function quotaPoolRowSig(item, idx) {
|
||||
return `${getEffectiveLocale()}:${idx}:${item.poolLabel}:${item.isActivePool}:${Boolean(item.isPending)}:${Boolean(item.showReserved)}:${item.minuteTick}:${item.poolData?.usedPct}:${item.poolData?.remainingPct}:${item.poolData?.reservedPct}:${item.poolData?.reservedLeaseCount}:${item.poolData?.resetTime}:${item.poolData?.weeklyUsedPct}:${item.poolData?.weeklyRemainingPct}:${item.poolData?.weeklyReservedPct}:${item.poolData?.weeklyReservedLeaseCount}:${item.poolData?.weeklyResetTime}:${c5h?.tokens}:${c5h?.costUsd}:${c5h?.calls}:${cWk?.tokens}:${cWk?.costUsd}:${cWk?.calls}:${fw?.isOfficial}:${fw?.usedPct}:${fw?.remainingPct}:${fw?.resetTime}:${fw?.title}:${fw?.tokens}:${fw?.costUsd}:${fw?.calls}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化可用额度面板右上角的账号订阅徽章(区分 Ultra 5x / 20x,并对 Pro / Free 去重)。
|
||||
*
|
||||
* @param {object|null|undefined} account
|
||||
* @returns {string}
|
||||
*/
|
||||
export function formatAccountTierBadge(account) {
|
||||
const tierName = String(account?.tierName || '').trim() || 'Google AI';
|
||||
const tierId = String(account?.tierId || '').trim().toLowerCase();
|
||||
const explicitMult = String(account?.tierMultiplier || '').trim();
|
||||
const inferredMult =
|
||||
explicitMult ||
|
||||
(/(?:^|[-_\s])5x(?:$|[-_\s])|ultra[-_]?lite/i.test(`${tierId} ${tierName}`)
|
||||
? '5x'
|
||||
: /(?:^|[-_\s])20x(?:$|[-_\s])/i.test(`${tierId} ${tierName}`) || tierId === 'g1-ultra-tier'
|
||||
? '20x'
|
||||
: '');
|
||||
const rawPlan = String(account?.planName || '').trim();
|
||||
const isUltra = /\bultra\b/i.test(tierName) || /ultra/i.test(tierId);
|
||||
|
||||
if (isUltra) {
|
||||
if (inferredMult) {
|
||||
const hasMultInTier = new RegExp(`(?:^|\\s|·)${inferredMult}(?:$|\\s)`, 'i').test(tierName);
|
||||
return hasMultInTier ? tierName : `${tierName} · ${inferredMult}`;
|
||||
}
|
||||
if (rawPlan && !/^(?:pro|ultra)$/i.test(rawPlan)) {
|
||||
return `${tierName} · ${rawPlan}`;
|
||||
}
|
||||
return tierName;
|
||||
}
|
||||
|
||||
if (!rawPlan) return tierName;
|
||||
const escapedPlan = rawPlan.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||
if (new RegExp(`(?:^|\\s|·)${escapedPlan}(?:$|\\s)`, 'i').test(tierName)) {
|
||||
return tierName;
|
||||
}
|
||||
return `${tierName} · ${rawPlan}`;
|
||||
}
|
||||
|
||||
export const QuotaPoolsWidget = defineComponent({
|
||||
name: 'QuotaPoolsWidget',
|
||||
setup({ props }) {
|
||||
@@ -392,6 +431,23 @@ export const QuotaPoolsWidget = defineComponent({
|
||||
});
|
||||
}
|
||||
|
||||
const legendActualTextEl = h('span', { text: t('quota.legendActual') });
|
||||
const legendReservedTextEl = h('span', { text: t('quota.legendReserved') });
|
||||
const reserveLegendEl = h(
|
||||
'div',
|
||||
{ className: 'quota-reserve-legend', hidden: true },
|
||||
[
|
||||
h('span', { className: 'quota-legend-item' }, [
|
||||
h('span', { className: 'quota-legend-line is-actual', 'aria-hidden': 'true' }),
|
||||
legendActualTextEl,
|
||||
]),
|
||||
h('span', { className: 'quota-legend-item' }, [
|
||||
h('span', { className: 'quota-legend-line is-reserved', 'aria-hidden': 'true' }),
|
||||
legendReservedTextEl,
|
||||
]),
|
||||
]
|
||||
);
|
||||
|
||||
const quotaPanel = h('section', { className: 'panel' }, [
|
||||
h('div', { className: 'panel-header' }, [
|
||||
h('span', { className: 'panel-title' }, [
|
||||
@@ -401,11 +457,15 @@ export const QuotaPoolsWidget = defineComponent({
|
||||
tierBadge,
|
||||
]),
|
||||
poolsListEl,
|
||||
reserveLegendEl,
|
||||
]);
|
||||
|
||||
function update({ data, minuteTick } = {}) {
|
||||
patchText(titleTextEl, t('module.quotas'));
|
||||
patchText(legendActualTextEl, t('quota.legendActual'));
|
||||
patchText(legendReservedTextEl, t('quota.legendReserved'));
|
||||
if (!data) {
|
||||
reserveLegendEl.hidden = true;
|
||||
if (compactHover) {
|
||||
patchKeyedList(poolsListEl, buildQuotaPoolItems(null, 0, { isPending: true }), {
|
||||
keyFn: (item) => item.key,
|
||||
@@ -419,11 +479,9 @@ export const QuotaPoolsWidget = defineComponent({
|
||||
|
||||
const quotas = data.quotas || {};
|
||||
const showReserved = data.settings?.experimentalQuotaReservation === true;
|
||||
reserveLegendEl.hidden = !showReserved;
|
||||
const effTick = Number.isFinite(minuteTick) ? minuteTick : Math.floor(Date.now() / 30000);
|
||||
patchText(
|
||||
tierBadge,
|
||||
`${data.account?.tierName || 'Google AI'} · ${data.account?.planName || 'Pro'}`
|
||||
);
|
||||
patchText(tierBadge, formatAccountTierBadge(data.account));
|
||||
patchKeyedList(poolsListEl, buildQuotaPoolItems(quotas, effTick, { showReserved }), {
|
||||
keyFn: (item) => item.key,
|
||||
sigFn: quotaPoolRowSig,
|
||||
|
||||
@@ -125,6 +125,7 @@ export const I18N_MESSAGES_EN_US = Object.freeze({
|
||||
'capMetric.quota_auto': 'Auto Tightest Quota',
|
||||
'capMetric.gemini_5h': 'Gemini 5h Quota',
|
||||
'capMetric.gemini_weekly': 'Gemini Weekly Quota',
|
||||
'capMetric.argon_weekly': 'Argon Weekly Quota',
|
||||
'capMetric.claude_5h': 'Claude 5h Quota',
|
||||
'capMetric.claude_weekly': 'Claude Weekly Quota',
|
||||
|
||||
@@ -187,6 +188,8 @@ export const I18N_MESSAGES_EN_US = Object.freeze({
|
||||
'quota.usedAfterReserved': ' · {rem}% left)',
|
||||
'quota.reservedTip': 'Estimated lease reservation (Experimental): ~{rsv}% (~{actual}% actual used); unused share refunds after ~10 min idle',
|
||||
'quota.reservedTipMulti': 'Estimated lease reservation (Experimental): ~{rsv}% ({leases} stacked leases, ~{actual}% actual used); unused share refunds after ~10 min idle',
|
||||
'quota.legendActual': 'Actual',
|
||||
'quota.legendReserved': 'Reserved',
|
||||
'quota.cycle5hTitle': 'Current 5h cycle ({pool}): {tok} Tokens · {cost} · {calls} calls',
|
||||
'quota.cycleWkCustomTitle': 'Current calendar week: {tok} Tokens · {cost} · {calls} calls',
|
||||
'quota.cycleWkPoolTitle': 'Current weekly cycle ({pool}): {tok} Tokens · {cost} · {calls} calls',
|
||||
@@ -691,7 +694,7 @@ export const I18N_MESSAGES_EN_US = Object.freeze({
|
||||
'settings.oth.quotaReserveLabel': 'Quota Reservation Estimate',
|
||||
'settings.oth.quotaReserveDesc': 'Estimate 0.5% / 1% 5h & weekly lease holds in Available Quotas and highlight the reserved share in violet',
|
||||
'settings.oth.quotaReserveLogLabel': 'Reservation Observation Log',
|
||||
'settings.oth.quotaReserveLogDesc': 'Copy in-memory quota jump & refund events to clipboard for threshold tuning',
|
||||
'settings.oth.quotaReserveLogDesc': 'Copy persisted quota jump & refund observations to clipboard (retained across restarts)',
|
||||
'settings.oth.exportReserveLogBtn': 'Export Reserve Log',
|
||||
'settings.oth.exportReserveLogCopied': 'Copied {count} log entries to clipboard',
|
||||
'settings.oth.exportReserveLogEmpty': 'No events yet; copied current summary to clipboard',
|
||||
@@ -731,7 +734,7 @@ export const I18N_MESSAGES_EN_US = Object.freeze({
|
||||
'settings.oth.resettingBtn': 'Resetting…',
|
||||
'settings.oth.resetAllDone': 'All preferences restored to defaults',
|
||||
'settings.oth.backupLabel': 'Preferences Backup & Restore',
|
||||
'settings.oth.backupDesc': 'Export or import portable UI, capsule, and table preferences as JSON (excludes credentials)',
|
||||
'settings.oth.backupDesc': 'Export or import portable UI, capsule, and table preferences as JSON',
|
||||
'settings.oth.exportJsonBtn': 'Export JSON',
|
||||
'settings.oth.importJsonBtn': 'Import JSON',
|
||||
'settings.oth.exportDone': 'Preferences JSON exported',
|
||||
@@ -745,7 +748,7 @@ export const I18N_MESSAGES_EN_US = Object.freeze({
|
||||
'settings.oth.migModeLabel': 'Migration Mode',
|
||||
'settings.oth.migModeMove': 'Full Move (Recommended)',
|
||||
'settings.oth.migModeClone': 'Clone Copy',
|
||||
'settings.oth.migModeMoveHint': 'Assigns an isolated target ID while preserving all historical steps/details; archives source backup before moving (close source session first)',
|
||||
'settings.oth.migModeMoveHint': 'Assigns an isolated target ID while preserving all historical steps/details; archives source backup before moving',
|
||||
'settings.oth.migModeCloneHint': 'Keeps source intact with a fresh UUID; only counts new steps generated after cloning',
|
||||
'settings.oth.migProjectLabel': 'Target Project',
|
||||
'settings.oth.migProjectOutside': 'Standalone (No Project)',
|
||||
|
||||
@@ -125,6 +125,7 @@ export const I18N_MESSAGES_ZH_CN = Object.freeze({
|
||||
'capMetric.quota_auto': '自动紧俏额度',
|
||||
'capMetric.gemini_5h': 'Gemini 5h 额度',
|
||||
'capMetric.gemini_weekly': 'Gemini 周额度',
|
||||
'capMetric.argon_weekly': 'Argon 周额度',
|
||||
'capMetric.claude_5h': 'Claude 5h 额度',
|
||||
'capMetric.claude_weekly': 'Claude 周额度',
|
||||
|
||||
@@ -187,6 +188,8 @@ export const I18N_MESSAGES_ZH_CN = Object.freeze({
|
||||
'quota.usedAfterReserved': ' · 余 {rem}%)',
|
||||
'quota.reservedTip': '预占估算(试验性):约 {rsv}%(实际已用约 {actual}%),静默约 10 分钟后未用差额自动退还',
|
||||
'quota.reservedTipMulti': '预占估算(试验性):约 {rsv}%(检测到 {leases} 笔叠加租约,实际已用约 {actual}%),静默约 10 分钟后未用差额自动退还',
|
||||
'quota.legendActual': '实占',
|
||||
'quota.legendReserved': '预占',
|
||||
'quota.cycle5hTitle': '当前 5h 周期累计 ({pool}):{tok} Tokens · {cost} · {calls} 次调用',
|
||||
'quota.cycleWkCustomTitle': '本周自然周累计:{tok} Tokens · {cost} · {calls} 次调用',
|
||||
'quota.cycleWkPoolTitle': '当前周限周期累计 ({pool}):{tok} Tokens · {cost} · {calls} 次调用',
|
||||
@@ -691,7 +694,7 @@ export const I18N_MESSAGES_ZH_CN = Object.freeze({
|
||||
'settings.oth.quotaReserveLabel': '配额预占估算',
|
||||
'settings.oth.quotaReserveDesc': '在可用额度中估算 5h / 周限的 0.5% / 1% 租约预占,并用紫色标注占比及进度条段',
|
||||
'settings.oth.quotaReserveLogLabel': '预占观测日志',
|
||||
'settings.oth.quotaReserveLogDesc': '将内存中的配额跳变及退还记录复制到剪贴板,便于分析触发阈值',
|
||||
'settings.oth.quotaReserveLogDesc': '将配额跳变及退还观测记录复制到剪贴板,重启后自动保留,便于分析触发阈值',
|
||||
'settings.oth.exportReserveLogBtn': '导出预占日志',
|
||||
'settings.oth.exportReserveLogCopied': '已复制 {count} 条观测日志到剪贴板',
|
||||
'settings.oth.exportReserveLogEmpty': '暂无跳变记录,已复制当前摘要到剪贴板',
|
||||
@@ -731,7 +734,7 @@ export const I18N_MESSAGES_ZH_CN = Object.freeze({
|
||||
'settings.oth.resettingBtn': '重置中…',
|
||||
'settings.oth.resetAllDone': '已恢复全部默认设置',
|
||||
'settings.oth.backupLabel': '配置备份及恢复',
|
||||
'settings.oth.backupDesc': '导出或导入外观、胶囊、列配置等便携偏好 JSON(不含账号凭证)',
|
||||
'settings.oth.backupDesc': '导出或导入外观、胶囊、列配置等便携偏好 JSON',
|
||||
'settings.oth.exportJsonBtn': '导出 JSON',
|
||||
'settings.oth.importJsonBtn': '导入 JSON',
|
||||
'settings.oth.exportDone': '配置 JSON 已导出',
|
||||
@@ -745,7 +748,7 @@ export const I18N_MESSAGES_ZH_CN = Object.freeze({
|
||||
'settings.oth.migModeLabel': '迁移方式',
|
||||
'settings.oth.migModeMove': '完整迁移(推荐)',
|
||||
'settings.oth.migModeClone': '克隆副本',
|
||||
'settings.oth.migModeMoveHint': '分配目标端独立会话 ID 并完整保留全部历史步序明细,备份后移出源端(零重复计费;迁移前建议先关闭源端该会话)',
|
||||
'settings.oth.migModeMoveHint': '分配目标端独立会话 ID 并完整保留全部历史步序明细,备份后移出源端',
|
||||
'settings.oth.migModeCloneHint': '保留源会话并生成新 ID,新副本仅统计迁入后的新步骤',
|
||||
'settings.oth.migProjectLabel': '绑定目标项目',
|
||||
'settings.oth.migProjectOutside': '独立会话(无所属项目)',
|
||||
|
||||
@@ -24,17 +24,28 @@ import { OVERVIEW_METRIC_KEYS, TOPBAR_SLOT_KEYS } from '../../shared/settings-no
|
||||
import {
|
||||
formatCompactCapsuleCost,
|
||||
formatCompactCapsuleTtft,
|
||||
hasArgonWeeklyQuotaPool,
|
||||
resolveCapsuleQuotaSlotPct,
|
||||
} from '../../shared/telemetry-display-rules.mjs';
|
||||
|
||||
export { OVERVIEW_METRIC_KEYS, formatCompactCapsuleCost, formatCompactCapsuleTtft };
|
||||
export {
|
||||
OVERVIEW_METRIC_KEYS,
|
||||
formatCompactCapsuleCost,
|
||||
formatCompactCapsuleTtft,
|
||||
hasArgonWeeklyQuotaPool,
|
||||
};
|
||||
export const CAPSULE_METRIC_KEYS = TOPBAR_SLOT_KEYS;
|
||||
|
||||
export function getCapsuleMetricOptions() {
|
||||
return CAPSULE_METRIC_KEYS.map((key) => ({
|
||||
value: key,
|
||||
label: t(`capMetric.${key}`),
|
||||
}));
|
||||
export function getCapsuleMetricOptions({ quotas = null, selectedSlots = [] } = {}) {
|
||||
const showArgonWeekly =
|
||||
hasArgonWeeklyQuotaPool(quotas) ||
|
||||
(Array.isArray(selectedSlots) && selectedSlots.includes('argon_weekly'));
|
||||
return CAPSULE_METRIC_KEYS.filter((key) => key !== 'argon_weekly' || showArgonWeekly).map(
|
||||
(key) => ({
|
||||
value: key,
|
||||
label: t(`capMetric.${key}`),
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
export function getOverviewMetricOptions() {
|
||||
@@ -97,17 +108,21 @@ export function resolveQuotaCapsuleSummary(quotas) {
|
||||
: `${tightest.label} ${tightest.windowTag} · ${runnerUp.label} ${runnerUp.windowTag} ${runnerPct}%`
|
||||
: `${tightest.label} · ${tightest.windowTag}`;
|
||||
const tightestIsClaude = /claude|gpt|fable|oss|third/i.test(String(tightest.label || ''));
|
||||
const tightestIsGemini = !tightestIsClaude && /gemini|argon|carbon|neon|flash|pro/i.test(String(tightest.label || ''));
|
||||
const tightestIsArgon = !tightestIsClaude && /\bargon\b/i.test(String(tightest.label || ''));
|
||||
const tightestIsGemini =
|
||||
!tightestIsClaude && !tightestIsArgon && /gemini|carbon|neon|flash|pro/i.test(String(tightest.label || ''));
|
||||
const tightestWinShort = tightest.windowTag === '5h' ? '5h' : isEnglishLocale() ? 'w' : '周';
|
||||
const poolPrefix = tightestIsClaude
|
||||
? `C${tightestWinShort}`
|
||||
: tightestIsGemini
|
||||
? `G${tightestWinShort}`
|
||||
: tightest.windowTag === '5h'
|
||||
? '5h'
|
||||
: isEnglishLocale()
|
||||
? 'Wk'
|
||||
: '周';
|
||||
: tightestIsArgon
|
||||
? `A${tightestWinShort}`
|
||||
: tightestIsGemini
|
||||
? `G${tightestWinShort}`
|
||||
: tightest.windowTag === '5h'
|
||||
? '5h'
|
||||
: isEnglishLocale()
|
||||
? 'Wk'
|
||||
: '周';
|
||||
return {
|
||||
roundedPct: rounded,
|
||||
shortText: t('capsule.quotaLeft', { pct: rounded }),
|
||||
@@ -126,6 +141,7 @@ function resolveQuotaCapsulePrefix(metricKey, quotaSum) {
|
||||
const isEn = isEnglishLocale();
|
||||
if (metricKey === 'gemini_5h') return 'G5h';
|
||||
if (metricKey === 'gemini_weekly') return isEn ? 'Gw' : 'G周';
|
||||
if (metricKey === 'argon_weekly') return isEn ? 'Aw' : 'A周';
|
||||
if (metricKey === 'claude_5h') return 'C5h';
|
||||
if (metricKey === 'claude_weekly') return isEn ? 'Cw' : 'C周';
|
||||
if (quotaSum?.poolPrefix) return quotaSum.poolPrefix;
|
||||
@@ -346,6 +362,22 @@ export function resolveCapsuleMetricPresentation(metricKey, slotCtx, ringCircumf
|
||||
};
|
||||
}
|
||||
|
||||
if (metricKey === 'argon_weekly' && slotCtx.hasTelemetry && !hasArgonWeeklyQuotaPool(slotCtx.quotas)) {
|
||||
return {
|
||||
hidden: true,
|
||||
metric: 'none',
|
||||
segClass: 'wm-cap-slot',
|
||||
textClass: 'wm-slot-text',
|
||||
showRing: false,
|
||||
dashOffset: ringCircumference,
|
||||
text: '',
|
||||
toneClass: '',
|
||||
running: false,
|
||||
warn: false,
|
||||
danger: false,
|
||||
};
|
||||
}
|
||||
|
||||
const quotaSum = !slotCtx.hasTelemetry
|
||||
? null
|
||||
: metricKey === 'quota_auto'
|
||||
|
||||
@@ -1038,7 +1038,9 @@ export function isEquivalentTelemetry(prev, next) {
|
||||
prev.account?.email !== next.account?.email ||
|
||||
prev.account?.name !== next.account?.name ||
|
||||
prev.account?.status !== next.account?.status ||
|
||||
prev.account?.tierId !== next.account?.tierId ||
|
||||
prev.account?.tierName !== next.account?.tierName ||
|
||||
prev.account?.tierMultiplier !== next.account?.tierMultiplier ||
|
||||
prev.account?.planName !== next.account?.planName ||
|
||||
prev.account?.aiCredits !== next.account?.aiCredits
|
||||
) {
|
||||
|
||||
@@ -628,11 +628,6 @@ html[data-standalone="true"][data-modern-ui="true"] .app-shell {
|
||||
margin: 4px 2px 2px;
|
||||
}
|
||||
|
||||
[data-modern-ui="true"] .sstep-anomaly-dot,
|
||||
[data-modern-ui="true"] .sstep-scatter-dot.is-anomaly {
|
||||
fill: var(--modern-surface-card);
|
||||
}
|
||||
|
||||
/* --- 6. 设置表单、折叠面板、槽位排序与输入控件去边框 --- */
|
||||
[data-modern-ui="true"] .collapsible-body,
|
||||
[data-modern-ui="true"] .settings-action-block + .settings-action-block,
|
||||
|
||||
@@ -580,13 +580,23 @@
|
||||
.progress-fill-reserved {
|
||||
height: 100%;
|
||||
width: var(--reserved-w, 0%);
|
||||
background: var(--quota-reserved);
|
||||
transition: width var(--dur-normal) var(--ease-fast);
|
||||
background: repeating-linear-gradient(
|
||||
-45deg,
|
||||
color-mix(in srgb, var(--quota-reserved) 72%, transparent) 0 2px,
|
||||
color-mix(in srgb, var(--quota-reserved) 26%, transparent) 2px 5px
|
||||
);
|
||||
transition:
|
||||
width var(--dur-normal) var(--ease-fast),
|
||||
margin-left var(--dur-fast) var(--ease-fast);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.progress-fill-reserved.is-active {
|
||||
min-width: 3px;
|
||||
min-width: 5px;
|
||||
}
|
||||
|
||||
.progress-fill-reserved.is-active.has-sep {
|
||||
margin-left: 1px;
|
||||
}
|
||||
|
||||
.quota-reserved-pct {
|
||||
@@ -594,6 +604,47 @@
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.quota-reserve-legend {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-top: 2px;
|
||||
padding-top: 2px;
|
||||
font-size: var(--fs-xs);
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.quota-reserve-legend[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.quota-legend-item {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.quota-legend-line {
|
||||
display: inline-block;
|
||||
width: 14px;
|
||||
height: 2px;
|
||||
border-radius: 1px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.quota-legend-line.is-actual {
|
||||
background: var(--accent-primary);
|
||||
}
|
||||
|
||||
.quota-legend-line.is-reserved {
|
||||
background: repeating-linear-gradient(
|
||||
90deg,
|
||||
var(--quota-reserved) 0 4px,
|
||||
transparent 4px 6.5px
|
||||
);
|
||||
}
|
||||
|
||||
/* --- 4. 上下文双列图例网格 (Context 10-Channel Legend Grid) --- */
|
||||
.ctx-legend-grid {
|
||||
display: grid;
|
||||
|
||||
@@ -896,18 +896,29 @@
|
||||
stroke: var(--metric-danger);
|
||||
}
|
||||
|
||||
.sstep-anomaly-dot,
|
||||
.sstep-scatter-dot.is-anomaly {
|
||||
fill: var(--surface-panel);
|
||||
fill-opacity: 1;
|
||||
.sstep-anomaly-dot {
|
||||
stroke: var(--metric-warn);
|
||||
stroke-width: 1.6;
|
||||
stroke-width: 1.5;
|
||||
stroke-opacity: 0.82;
|
||||
stroke-linecap: round;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.sstep-anomaly-dot.is-danger,
|
||||
.sstep-scatter-dot.is-anomaly.is-danger {
|
||||
.sstep-anomaly-dot.is-danger {
|
||||
stroke: var(--metric-danger);
|
||||
stroke-opacity: 0.92;
|
||||
}
|
||||
|
||||
.sstep-scatter-dot.is-anomaly {
|
||||
fill: var(--metric-warn);
|
||||
fill-opacity: 0.88;
|
||||
stroke: none;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.sstep-scatter-dot.is-anomaly.is-danger {
|
||||
fill: var(--metric-danger);
|
||||
fill-opacity: 0.92;
|
||||
}
|
||||
|
||||
.trend-tip-anomaly {
|
||||
|
||||
@@ -108,7 +108,8 @@ export const SettingsView = defineComponent({
|
||||
settings,
|
||||
telemetry?.windowBridge,
|
||||
telemetry?.hostPlatform,
|
||||
telemetry?.cliStatusLine
|
||||
telemetry?.cliStatusLine,
|
||||
telemetry?.quotas
|
||||
);
|
||||
}
|
||||
} else if (settingsSubTab === 'other') {
|
||||
|
||||
@@ -14,6 +14,7 @@ import { createSvgIcon } from '../../icons/SvgIcon.js';
|
||||
import {
|
||||
getCapsuleMetricOptions,
|
||||
getOverviewMetricOptions,
|
||||
hasArgonWeeklyQuotaPool,
|
||||
resolveSpecificQuotaSlotSummary,
|
||||
} from '../../registries/metricRegistry.js';
|
||||
import { getStepColumnOptions } from '../../registries/stepColumnRegistry.js';
|
||||
@@ -196,6 +197,15 @@ function formatCliPreviewSlot(slotKey, slotCtx, isEn) {
|
||||
pillPct: pct,
|
||||
};
|
||||
}
|
||||
case 'argon_weekly': {
|
||||
const pct = quotaPct('argon_weekly', 42);
|
||||
return {
|
||||
prefix: isEn ? 'Aw ' : 'A周 ',
|
||||
text: `${pct}%`,
|
||||
tone: 'good',
|
||||
pillPct: pct,
|
||||
};
|
||||
}
|
||||
case 'claude_5h': {
|
||||
const pct = quotaPct('claude_5h', 32);
|
||||
return {
|
||||
@@ -255,6 +265,7 @@ export const SettingsStructureTab = defineComponent({
|
||||
let latestWindowBridge = null;
|
||||
let latestCliStatusLine = null;
|
||||
let latestHostPlatform = 'win32';
|
||||
let latestQuotas = null;
|
||||
|
||||
function getEffectiveDraftCliSlots() {
|
||||
return resolveEffectiveClientCliStatusLineSlots({
|
||||
@@ -269,25 +280,34 @@ export const SettingsStructureTab = defineComponent({
|
||||
}
|
||||
|
||||
function buildDraftTelemetry() {
|
||||
return buildStructurePreviewTelemetry(latestSettings, {
|
||||
windowMountMode: draftWindowMountMode,
|
||||
enableWindowOverlay: draftWindowMountMode !== 'sidebar',
|
||||
popoverWidthMode: draftPopoverWidthMode,
|
||||
popoverWidth: draftPopoverWidth,
|
||||
enableCliStatusLine: draftEnableCliStatusLine,
|
||||
showTopbarMultiSession: draftShowTopbarMulti,
|
||||
contextAgentMode: draftContextAgentMode,
|
||||
topbarCapsuleSlots: draftTopbarSlots,
|
||||
hoverModules: draftHoverModules,
|
||||
overviewModules: draftOverviewModules,
|
||||
overviewMetrics: draftOverviewMetrics,
|
||||
showStepTurnRail: draftShowStepTurnRail,
|
||||
showStepAgentBadge: draftShowStepAgentBadge,
|
||||
showStepSpeedColor: draftShowStepSpeedColor,
|
||||
showStepFilterToolbar: draftShowStepFilterToolbar,
|
||||
stepTokenComboFormat: draftStepTokenComboFormat,
|
||||
stepTableColumns: draftStepColumns,
|
||||
});
|
||||
const effectiveCliSlots = getEffectiveDraftCliSlots();
|
||||
const includeArgonPool =
|
||||
hasArgonWeeklyQuotaPool(latestQuotas) ||
|
||||
draftTopbarSlots.includes('argon_weekly') ||
|
||||
effectiveCliSlots.includes('argon_weekly');
|
||||
return buildStructurePreviewTelemetry(
|
||||
latestSettings,
|
||||
{
|
||||
windowMountMode: draftWindowMountMode,
|
||||
enableWindowOverlay: draftWindowMountMode !== 'sidebar',
|
||||
popoverWidthMode: draftPopoverWidthMode,
|
||||
popoverWidth: draftPopoverWidth,
|
||||
enableCliStatusLine: draftEnableCliStatusLine,
|
||||
showTopbarMultiSession: draftShowTopbarMulti,
|
||||
contextAgentMode: draftContextAgentMode,
|
||||
topbarCapsuleSlots: draftTopbarSlots,
|
||||
hoverModules: draftHoverModules,
|
||||
overviewModules: draftOverviewModules,
|
||||
overviewMetrics: draftOverviewMetrics,
|
||||
showStepTurnRail: draftShowStepTurnRail,
|
||||
showStepAgentBadge: draftShowStepAgentBadge,
|
||||
showStepSpeedColor: draftShowStepSpeedColor,
|
||||
showStepFilterToolbar: draftShowStepFilterToolbar,
|
||||
stepTokenComboFormat: draftStepTokenComboFormat,
|
||||
stepTableColumns: draftStepColumns,
|
||||
},
|
||||
{ includeArgonPool }
|
||||
);
|
||||
}
|
||||
|
||||
async function persistStructurePatch(sectionComp, patchObj, successKey = 'settings.saved') {
|
||||
@@ -780,7 +800,10 @@ export const SettingsStructureTab = defineComponent({
|
||||
const effectiveCliSlots = getEffectiveDraftCliSlots();
|
||||
cliSlotsList.refs.setProps({
|
||||
items: effectiveCliSlots,
|
||||
options: getCapsuleMetricOptions(),
|
||||
options: getCapsuleMetricOptions({
|
||||
quotas: latestQuotas,
|
||||
selectedSlots: effectiveCliSlots,
|
||||
}),
|
||||
addBtnTextFn: (count, max) => t('settings.str.addCliSlot', { count, max }),
|
||||
});
|
||||
const preservedCustom = Boolean(latestCliStatusLine?.preservedCustom);
|
||||
@@ -819,7 +842,10 @@ export const SettingsStructureTab = defineComponent({
|
||||
refreshCliPreview();
|
||||
topbarSlotsList.refs.setProps({
|
||||
items: draftTopbarSlots,
|
||||
options: getCapsuleMetricOptions(),
|
||||
options: getCapsuleMetricOptions({
|
||||
quotas: latestQuotas,
|
||||
selectedSlots: draftTopbarSlots,
|
||||
}),
|
||||
addBtnTextFn: (count, max) => t('settings.str.addCapsuleSlot', { count, max }),
|
||||
});
|
||||
mountSection.refs.setBadge(
|
||||
@@ -1431,13 +1457,15 @@ export const SettingsStructureTab = defineComponent({
|
||||
settings,
|
||||
windowBridge = latestWindowBridge,
|
||||
hostPlatform = latestHostPlatform,
|
||||
cliStatusLine = latestCliStatusLine
|
||||
cliStatusLine = latestCliStatusLine,
|
||||
quotas = latestQuotas
|
||||
) {
|
||||
if (!settings) return;
|
||||
latestSettings = settings;
|
||||
if (windowBridge !== undefined) latestWindowBridge = windowBridge;
|
||||
if (hostPlatform) latestHostPlatform = hostPlatform;
|
||||
if (cliStatusLine !== undefined) latestCliStatusLine = cliStatusLine;
|
||||
if (quotas !== undefined) latestQuotas = quotas;
|
||||
draftWindowMountMode = normalizeClientWindowMountMode(
|
||||
settings.windowMountMode,
|
||||
settings.enableWindowOverlay
|
||||
|
||||
Reference in New Issue
Block a user