mirror of
https://github.com/lWolvesl/antigravity-usage-monitor.git
synced 2026-11-26 17:09:28 +08:00
feat(cli): upgrade statusLine context and quota gauges to 24-bit background pills
This commit is contained in:
@@ -33,7 +33,7 @@ import {
|
|||||||
resolveCapsuleQuotaSlotPct,
|
resolveCapsuleQuotaSlotPct,
|
||||||
} from '../shared/telemetry-display-rules.mjs';
|
} from '../shared/telemetry-display-rules.mjs';
|
||||||
|
|
||||||
// 24-bit ANSI 前景 SGR 调色板(透明底色,与桌面端四档语义色阶及 CLI 原生底栏色调对齐,无任何背景填充或非 SGR 控制符)
|
// 24-bit ANSI SGR 调色板(和桌面端语义色阶及 CLI 原生底栏对齐;上下文和配额槽位采用 24-bit 底色胶囊填充,零 OSC 序列)
|
||||||
const SGR_RESET = '\x1b[0m';
|
const SGR_RESET = '\x1b[0m';
|
||||||
const SGR_BOLD = '\x1b[1m';
|
const SGR_BOLD = '\x1b[1m';
|
||||||
const SGR_FG_BRIGHT = '\x1b[38;2;226;232;240m';
|
const SGR_FG_BRIGHT = '\x1b[38;2;226;232;240m';
|
||||||
@@ -44,7 +44,6 @@ const SGR_FG_CHROME = '\x1b[38;2;136;142;150m';
|
|||||||
const SGR_FG_SEP = '\x1b[38;2;110;122;140m';
|
const SGR_FG_SEP = '\x1b[38;2;110;122;140m';
|
||||||
const SGR_FG_DOT_IDLE = '\x1b[38;2;100;116;139m';
|
const SGR_FG_DOT_IDLE = '\x1b[38;2;100;116;139m';
|
||||||
const SGR_FG_ACCENT = '\x1b[38;2;96;165;250m';
|
const SGR_FG_ACCENT = '\x1b[38;2;96;165;250m';
|
||||||
const SGR_FG_TEAL = '\x1b[38;2;45;212;191m';
|
|
||||||
const SGR_FG_GOOD = '\x1b[38;2;52;211;153m';
|
const SGR_FG_GOOD = '\x1b[38;2;52;211;153m';
|
||||||
const SGR_FG_INFO = '\x1b[38;2;56;189;248m';
|
const SGR_FG_INFO = '\x1b[38;2;56;189;248m';
|
||||||
const SGR_FG_WARN = '\x1b[38;2;251;191;36m';
|
const SGR_FG_WARN = '\x1b[38;2;251;191;36m';
|
||||||
@@ -52,6 +51,20 @@ const SGR_FG_DANGER = '\x1b[38;2;248;113;113m';
|
|||||||
const SGR_FG_MODE_AUTO = '\x1b[38;2;234;179;8m';
|
const SGR_FG_MODE_AUTO = '\x1b[38;2;234;179;8m';
|
||||||
const SGR_FG_MODE_VIOLET = '\x1b[38;2;192;132;252m';
|
const SGR_FG_MODE_VIOLET = '\x1b[38;2;192;132;252m';
|
||||||
|
|
||||||
|
// 底色胶囊专用 24-bit 背景和前景对比色(深灰暗轨 + 四档低刺眼饱和填充底色 + 亮白数字)
|
||||||
|
const SGR_BG_PILL_TRACK = '\x1b[48;2;36;40;50m';
|
||||||
|
const SGR_BG_PILL_BLUE = '\x1b[48;2;36;72;128m';
|
||||||
|
const SGR_BG_PILL_GREEN = '\x1b[48;2;24;96;68m';
|
||||||
|
const SGR_BG_PILL_WARN = '\x1b[48;2;116;84;22m';
|
||||||
|
const SGR_BG_PILL_DANGER = '\x1b[48;2;124;42;48m';
|
||||||
|
const SGR_FG_PILL_LABEL_TRACK = '\x1b[38;2;176;186;202m';
|
||||||
|
const SGR_FG_PILL_VAL_TRACK = `${SGR_BOLD}\x1b[38;2;238;242;248m`;
|
||||||
|
const SGR_FG_PILL_LABEL_BLUE = '\x1b[38;2;216;230;250m';
|
||||||
|
const SGR_FG_PILL_LABEL_GREEN = '\x1b[38;2;210;244;228m';
|
||||||
|
const SGR_FG_PILL_LABEL_WARN = '\x1b[38;2;254;240;199m';
|
||||||
|
const SGR_FG_PILL_LABEL_DANGER = '\x1b[38;2;254;222;224m';
|
||||||
|
const SGR_FG_PILL_VAL_FILLED = `${SGR_BOLD}\x1b[38;2;248;250;252m`;
|
||||||
|
|
||||||
function isCliStatusPlainObject(v) {
|
function isCliStatusPlainObject(v) {
|
||||||
return Boolean(v) && typeof v === 'object' && !Array.isArray(v);
|
return Boolean(v) && typeof v === 'object' && !Array.isArray(v);
|
||||||
}
|
}
|
||||||
@@ -691,24 +704,71 @@ function cliComposeBalancedThreeColumn(leftStr, centerStr, rightStr, maxWidth) {
|
|||||||
return cw <= maxWidth ? centerStr : '';
|
return cw <= maxWidth ? centerStr : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function cliBuildMiniProgressBar(
|
/**
|
||||||
|
* 将标签和百分比渲染为从左往右按占比填充背景的 24-bit 底色胶囊(如 ` 上下文 17% ` / ` G5h 83% `)。
|
||||||
|
* 百分比按 3-4 列右对齐以防数值变化引起整行抖动,CJK 全角字符按 2 列中点判定归属。
|
||||||
|
*/
|
||||||
|
function cliBuildPillGauge(
|
||||||
|
label,
|
||||||
pct,
|
pct,
|
||||||
{ width = 8, fillSgr = SGR_FG_TEAL, emptyChar = '⢕', useColor = true } = {}
|
{
|
||||||
|
fillBg = SGR_BG_PILL_BLUE,
|
||||||
|
fillLabelFg = SGR_FG_PILL_LABEL_BLUE,
|
||||||
|
fillValFg = SGR_FG_PILL_VAL_FILLED,
|
||||||
|
trackBg = SGR_BG_PILL_TRACK,
|
||||||
|
trackLabelFg = SGR_FG_PILL_LABEL_TRACK,
|
||||||
|
trackValFg = SGR_FG_PILL_VAL_TRACK,
|
||||||
|
} = {}
|
||||||
) {
|
) {
|
||||||
if (!(width > 0)) return '';
|
const clamped = Math.max(0, Math.min(100, Number(pct) || 0));
|
||||||
const clamped = Math.max(0, Math.min(100, Number(pct)));
|
const valStr = `${Math.round(clamped)}%`.padStart(3, ' ');
|
||||||
let filled = Math.round((clamped / 100) * width);
|
const prefixText = ` ${label} `;
|
||||||
if (clamped > 0 && filled === 0) filled = 1;
|
const valText = `${valStr} `;
|
||||||
if (clamped < 95 && filled >= width) filled = Math.max(0, width - 1);
|
|
||||||
const empty = Math.max(0, width - filled);
|
const cells = [];
|
||||||
const filledStr = '█'.repeat(filled);
|
let totalCols = 0;
|
||||||
const emptyStr = emptyChar.repeat(empty);
|
for (const ch of prefixText) {
|
||||||
if (!useColor) {
|
const w = cliDisplayWidth(ch) || 1;
|
||||||
return `${filledStr}${emptyStr}`;
|
cells.push({ ch, w, col: totalCols, isVal: false });
|
||||||
|
totalCols += w;
|
||||||
}
|
}
|
||||||
const fillPart = filledStr ? `${fillSgr}${filledStr}` : '';
|
for (const ch of valText) {
|
||||||
const emptyPart = emptyStr ? `${SGR_FG_DIM}${emptyStr}` : '';
|
const w = cliDisplayWidth(ch) || 1;
|
||||||
return `${fillPart}${emptyPart}${SGR_RESET}`;
|
cells.push({ ch, w, col: totalCols, isVal: true });
|
||||||
|
totalCols += w;
|
||||||
|
}
|
||||||
|
|
||||||
|
const exactFill = (clamped / 100) * totalCols;
|
||||||
|
const lastIdx = cells.length - 1;
|
||||||
|
let out = '';
|
||||||
|
let curStyle = '';
|
||||||
|
|
||||||
|
for (let i = 0; i < cells.length; i += 1) {
|
||||||
|
const cell = cells[i];
|
||||||
|
let isFilled = clamped > 0 && cell.col + cell.w / 2 <= exactFill;
|
||||||
|
if (i === 0 && clamped > 0) isFilled = true;
|
||||||
|
if (i === lastIdx && clamped < 96) isFilled = false;
|
||||||
|
if (clamped >= 100) isFilled = true;
|
||||||
|
|
||||||
|
const bg = isFilled ? fillBg : trackBg;
|
||||||
|
const fg = isFilled
|
||||||
|
? cell.isVal
|
||||||
|
? fillValFg
|
||||||
|
: fillLabelFg
|
||||||
|
: cell.isVal
|
||||||
|
? trackValFg
|
||||||
|
: trackLabelFg;
|
||||||
|
const style = `${bg}${fg}`;
|
||||||
|
if (style !== curStyle) {
|
||||||
|
// 切换样式时若此前带粗体而目标不带粗体,先重置再写入避免粗体残留
|
||||||
|
const prevBold = curStyle.includes(SGR_BOLD);
|
||||||
|
const nextBold = style.includes(SGR_BOLD);
|
||||||
|
out += prevBold && !nextBold ? `${SGR_RESET}${style}` : style;
|
||||||
|
curStyle = style;
|
||||||
|
}
|
||||||
|
out += cell.ch;
|
||||||
|
}
|
||||||
|
return `${out}${SGR_RESET}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function cliResolveQuotaSlotPrefix(metricKey, isEn) {
|
function cliResolveQuotaSlotPrefix(metricKey, isEn) {
|
||||||
@@ -720,12 +780,12 @@ function cliResolveQuotaSlotPrefix(metricKey, isEn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将单槽位指标格式化为纯文本及无背景前景语义 SGR 片段。
|
* 将单槽位指标格式化为纯文本及 24-bit 终端语义 SGR 片段(上下文和配额支持底色胶囊填充)。
|
||||||
*/
|
*/
|
||||||
function cliRenderSingleSlot(
|
function cliRenderSingleSlot(
|
||||||
metricKey,
|
metricKey,
|
||||||
slotCtx,
|
slotCtx,
|
||||||
{ isEn = false, useColor = true, slotSet, barWidth = 8 } = {}
|
{ isEn = false, useColor = true, slotSet, usePill = true } = {}
|
||||||
) {
|
) {
|
||||||
const hasTelemetry = slotCtx.hasTelemetry !== false;
|
const hasTelemetry = slotCtx.hasTelemetry !== false;
|
||||||
|
|
||||||
@@ -734,24 +794,23 @@ function cliRenderSingleSlot(
|
|||||||
const pctNum = valid ? Math.max(0, Math.min(100, Math.round(Number(slotCtx.usedPct)))) : null;
|
const pctNum = valid ? Math.max(0, Math.min(100, Math.round(Number(slotCtx.usedPct)))) : null;
|
||||||
const label = isEn ? 'Ctx' : '上下文';
|
const label = isEn ? 'Ctx' : '上下文';
|
||||||
const textVal = pctNum != null ? `${pctNum}%` : '--%';
|
const textVal = pctNum != null ? `${pctNum}%` : '--%';
|
||||||
|
if (!useColor) {
|
||||||
|
return `${label} ${textVal}`;
|
||||||
|
}
|
||||||
const isDanger = pctNum != null && pctNum >= 88;
|
const isDanger = pctNum != null && pctNum >= 88;
|
||||||
const isWarn = !isDanger && pctNum != null && pctNum >= 70;
|
const isWarn = !isDanger && pctNum != null && pctNum >= 70;
|
||||||
const isMid = !isDanger && !isWarn && pctNum != null && pctNum >= 50;
|
if (usePill && pctNum != null) {
|
||||||
const barColor = isDanger
|
const fillBg = isDanger
|
||||||
? SGR_FG_DANGER
|
? SGR_BG_PILL_DANGER
|
||||||
: isWarn
|
: isWarn
|
||||||
? SGR_FG_WARN
|
? SGR_BG_PILL_WARN
|
||||||
: isMid
|
: SGR_BG_PILL_BLUE;
|
||||||
? SGR_FG_ACCENT
|
const fillLabelFg = isDanger
|
||||||
: pctNum != null
|
? SGR_FG_PILL_LABEL_DANGER
|
||||||
? SGR_FG_TEAL
|
: isWarn
|
||||||
: SGR_FG_MUTED;
|
? SGR_FG_PILL_LABEL_WARN
|
||||||
const barSegment =
|
: SGR_FG_PILL_LABEL_BLUE;
|
||||||
barWidth > 0 && pctNum != null
|
return cliBuildPillGauge(label, pctNum, { fillBg, fillLabelFg });
|
||||||
? `${cliBuildMiniProgressBar(pctNum, { width: barWidth, fillSgr: barColor, emptyChar: '⢕', useColor })} `
|
|
||||||
: '';
|
|
||||||
if (!useColor) {
|
|
||||||
return `${label} ${barSegment}${textVal}`;
|
|
||||||
}
|
}
|
||||||
const valColor = isDanger
|
const valColor = isDanger
|
||||||
? `${SGR_BOLD}${SGR_FG_DANGER}`
|
? `${SGR_BOLD}${SGR_FG_DANGER}`
|
||||||
@@ -760,7 +819,7 @@ function cliRenderSingleSlot(
|
|||||||
: pctNum != null
|
: pctNum != null
|
||||||
? `${SGR_BOLD}${SGR_FG_BRIGHT}`
|
? `${SGR_BOLD}${SGR_FG_BRIGHT}`
|
||||||
: SGR_FG_MUTED;
|
: SGR_FG_MUTED;
|
||||||
return `${SGR_FG_MUTED}${label} ${barSegment}${valColor}${textVal}${SGR_RESET}`;
|
return `${SGR_FG_MUTED}${label} ${valColor}${textVal}${SGR_RESET}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (metricKey === 'tps') {
|
if (metricKey === 'tps') {
|
||||||
@@ -854,20 +913,12 @@ function cliRenderSingleSlot(
|
|||||||
const prefix = cliResolveQuotaSlotPrefix(metricKey, isEn);
|
const prefix = cliResolveQuotaSlotPrefix(metricKey, isEn);
|
||||||
const isDanger = quotaPct != null && quotaPct <= 15;
|
const isDanger = quotaPct != null && quotaPct <= 15;
|
||||||
const isWarn = !isDanger && quotaPct != null && quotaPct <= 30;
|
const isWarn = !isDanger && quotaPct != null && quotaPct <= 30;
|
||||||
const isMid = !isDanger && !isWarn && quotaPct != null && quotaPct <= 60;
|
|
||||||
const fillSgr = isDanger
|
|
||||||
? SGR_FG_DANGER
|
|
||||||
: isWarn
|
|
||||||
? SGR_FG_WARN
|
|
||||||
: isMid
|
|
||||||
? SGR_FG_INFO
|
|
||||||
: SGR_FG_GOOD;
|
|
||||||
const pctSgr = isDanger
|
const pctSgr = isDanger
|
||||||
? `${SGR_BOLD}${SGR_FG_DANGER}`
|
? `${SGR_BOLD}${SGR_FG_DANGER}`
|
||||||
: isWarn
|
: isWarn
|
||||||
? `${SGR_BOLD}${SGR_FG_WARN}`
|
? `${SGR_BOLD}${SGR_FG_WARN}`
|
||||||
: quotaPct != null
|
: quotaPct != null
|
||||||
? SGR_FG_NORMAL
|
? SGR_FG_GOOD
|
||||||
: SGR_FG_MUTED;
|
: SGR_FG_MUTED;
|
||||||
|
|
||||||
if (quotaPct == null) {
|
if (quotaPct == null) {
|
||||||
@@ -876,27 +927,25 @@ function cliRenderSingleSlot(
|
|||||||
return useColor ? `${SGR_FG_MUTED}${emptyText}${SGR_RESET}` : emptyText;
|
return useColor ? `${SGR_FG_MUTED}${emptyText}${SGR_RESET}` : emptyText;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (barWidth > 0) {
|
|
||||||
const bar = cliBuildMiniProgressBar(quotaPct, {
|
|
||||||
width: barWidth,
|
|
||||||
fillSgr,
|
|
||||||
emptyChar: '⣿',
|
|
||||||
useColor,
|
|
||||||
});
|
|
||||||
if (!useColor) {
|
if (!useColor) {
|
||||||
return `${prefix} ${bar} ${quotaPct}%`;
|
return `${prefix} ${quotaPct}%`;
|
||||||
}
|
|
||||||
return `${SGR_FG_MUTED}${prefix} ${bar} ${pctSgr}${quotaPct}%${SGR_RESET}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const compactText =
|
if (usePill) {
|
||||||
metricKey === 'quota_auto'
|
const fillBg = isDanger
|
||||||
? isEn
|
? SGR_BG_PILL_DANGER
|
||||||
? `${quotaPct}% left`
|
: isWarn
|
||||||
: `余 ${quotaPct}%`
|
? SGR_BG_PILL_WARN
|
||||||
: `${prefix} ${quotaPct}%`;
|
: SGR_BG_PILL_GREEN;
|
||||||
if (!useColor) return compactText;
|
const fillLabelFg = isDanger
|
||||||
return `${pctSgr}${compactText}${SGR_RESET}`;
|
? SGR_FG_PILL_LABEL_DANGER
|
||||||
|
: isWarn
|
||||||
|
? SGR_FG_PILL_LABEL_WARN
|
||||||
|
: SGR_FG_PILL_LABEL_GREEN;
|
||||||
|
return cliBuildPillGauge(prefix, quotaPct, { fillBg, fillLabelFg });
|
||||||
|
}
|
||||||
|
|
||||||
|
return `${SGR_FG_MUTED}${prefix} ${pctSgr}${quotaPct}%${SGR_RESET}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1110,12 +1159,12 @@ export function formatCliStatusLineCapsule(slotCtx = {}, options = {}) {
|
|||||||
? cliStatusFormatAnomalyTag(slotCtx.latestAnomaly, { isEn, useColor })
|
? cliStatusFormatAnomalyTag(slotCtx.latestAnomaly, { isEn, useColor })
|
||||||
: '';
|
: '';
|
||||||
|
|
||||||
const defaultBarWidth = options.showProgressBars === false ? 0 : 8;
|
const defaultUsePill = options.showProgressBars !== false;
|
||||||
|
|
||||||
const buildCapsulesForSlots = (slotList, includeAnomaly = true, barWidth = defaultBarWidth) => {
|
const buildCapsulesForSlots = (slotList, includeAnomaly = true, usePill = defaultUsePill) => {
|
||||||
const slotSet = new Set(slotList);
|
const slotSet = new Set(slotList);
|
||||||
const rendered = slotList.map((key) =>
|
const rendered = slotList.map((key) =>
|
||||||
cliRenderSingleSlot(key, slotCtx, { isEn, useColor, slotSet, barWidth })
|
cliRenderSingleSlot(key, slotCtx, { isEn, useColor, slotSet, usePill })
|
||||||
);
|
);
|
||||||
if (includeAnomaly && anomalyBadge) {
|
if (includeAnomaly && anomalyBadge) {
|
||||||
rendered.push(anomalyBadge);
|
rendered.push(anomalyBadge);
|
||||||
@@ -1128,7 +1177,7 @@ export function formatCliStatusLineCapsule(slotCtx = {}, options = {}) {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const baseCapsules = buildCapsulesForSlots(activeSlots, true, defaultBarWidth);
|
const baseCapsules = buildCapsulesForSlots(activeSlots, true, defaultUsePill);
|
||||||
const rawWidth = Number(options.terminalWidth);
|
const rawWidth = Number(options.terminalWidth);
|
||||||
if (!Number.isFinite(rawWidth) || rawWidth <= 0) {
|
if (!Number.isFinite(rawWidth) || rawWidth <= 0) {
|
||||||
return baseCapsules.fullCapsule;
|
return baseCapsules.fullCapsule;
|
||||||
@@ -1167,44 +1216,32 @@ export function formatCliStatusLineCapsule(slotCtx = {}, options = {}) {
|
|||||||
);
|
);
|
||||||
if (fullPrimary) return fullPrimary;
|
if (fullPrimary) return fullPrimary;
|
||||||
|
|
||||||
// 中等终端优先把进度条从 8 格微缩至 5 格以保住左右完整原生提示,再逐级收缩左右栏和槽位
|
|
||||||
if (defaultBarWidth > 5) {
|
|
||||||
const compactBarCapsules = buildCapsulesForSlots(activeSlots, true, 5);
|
|
||||||
const fullCompactBar = cliComposeBalancedThreeColumn(
|
|
||||||
fullLeft,
|
|
||||||
compactBarCapsules.fullCapsule,
|
|
||||||
fullRight,
|
|
||||||
maxWidth
|
|
||||||
);
|
|
||||||
if (fullCompactBar) return fullCompactBar;
|
|
||||||
}
|
|
||||||
|
|
||||||
const primaryComposed = tryCompose(baseCapsules);
|
const primaryComposed = tryCompose(baseCapsules);
|
||||||
if (primaryComposed) return primaryComposed;
|
if (primaryComposed) return primaryComposed;
|
||||||
|
|
||||||
if (defaultBarWidth > 5) {
|
if (defaultUsePill) {
|
||||||
const compactBarCapsules = buildCapsulesForSlots(activeSlots, true, 5);
|
const noPillCapsules = buildCapsulesForSlots(activeSlots, true, false);
|
||||||
const compactBarComposed = tryCompose(compactBarCapsules);
|
const noPillComposed = tryCompose(noPillCapsules);
|
||||||
if (compactBarComposed) return compactBarComposed;
|
if (noPillComposed) return noPillComposed;
|
||||||
}
|
|
||||||
if (defaultBarWidth > 0) {
|
|
||||||
const noBarCapsules = buildCapsulesForSlots(activeSlots, true, 0);
|
|
||||||
const noBarComposed = tryCompose(noBarCapsules);
|
|
||||||
if (noBarComposed) return noBarComposed;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let reducedSlots = [...activeSlots];
|
let reducedSlots = [...activeSlots];
|
||||||
while (reducedSlots.length > 1) {
|
while (reducedSlots.length > 1) {
|
||||||
reducedSlots = cliStatusShedLowestPrioritySlot(reducedSlots);
|
reducedSlots = cliStatusShedLowestPrioritySlot(reducedSlots);
|
||||||
const reducedCap = buildCapsulesForSlots(reducedSlots, true, 0);
|
const reducedCap = buildCapsulesForSlots(reducedSlots, true, defaultUsePill);
|
||||||
const composed = tryCompose(reducedCap);
|
const composed = tryCompose(reducedCap);
|
||||||
if (composed) return composed;
|
if (composed) return composed;
|
||||||
|
if (defaultUsePill) {
|
||||||
|
const reducedPlain = buildCapsulesForSlots(reducedSlots, true, false);
|
||||||
|
const composedPlain = tryCompose(reducedPlain);
|
||||||
|
if (composedPlain) return composedPlain;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cliDisplayWidth(baseCapsules.fullCapsule) <= maxWidth) {
|
if (cliDisplayWidth(baseCapsules.fullCapsule) <= maxWidth) {
|
||||||
return baseCapsules.fullCapsule;
|
return baseCapsules.fullCapsule;
|
||||||
}
|
}
|
||||||
const minimalCap = buildCapsulesForSlots(reducedSlots, false, 0);
|
const minimalCap = buildCapsulesForSlots(reducedSlots, false, false);
|
||||||
if (cliDisplayWidth(minimalCap.fullCapsule) <= maxWidth) {
|
if (cliDisplayWidth(minimalCap.fullCapsule) <= maxWidth) {
|
||||||
return minimalCap.fullCapsule;
|
return minimalCap.fullCapsule;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1428,6 +1428,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.cli-preview-slot {
|
.cli-preview-slot {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
color: var(--text-primary);
|
color: var(--text-primary);
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
@@ -1453,38 +1455,53 @@
|
|||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cli-preview-bar-fill {
|
|
||||||
letter-spacing: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cli-preview-bar-empty {
|
|
||||||
color: var(--text-muted);
|
|
||||||
opacity: 0.65;
|
|
||||||
letter-spacing: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cli-preview-val {
|
.cli-preview-val {
|
||||||
color: var(--text-primary);
|
color: var(--text-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.cli-preview-slot.tone-good .cli-preview-val,
|
.cli-preview-slot.tone-good .cli-preview-val {
|
||||||
.cli-preview-slot.tone-good .cli-preview-bar-fill {
|
|
||||||
color: var(--metric-ok);
|
color: var(--metric-ok);
|
||||||
}
|
}
|
||||||
|
|
||||||
.cli-preview-slot.tone-info .cli-preview-val,
|
.cli-preview-slot.tone-info .cli-preview-val {
|
||||||
.cli-preview-slot.tone-info .cli-preview-bar-fill {
|
|
||||||
color: var(--metric-info);
|
color: var(--metric-info);
|
||||||
}
|
}
|
||||||
|
|
||||||
.cli-preview-slot.tone-accent .cli-preview-bar-fill {
|
|
||||||
color: var(--accent-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.cli-preview-slot.tone-muted .cli-preview-val {
|
.cli-preview-slot.tone-muted .cli-preview-val {
|
||||||
color: var(--text-secondary);
|
color: var(--text-secondary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.cli-preview-slot.is-pill {
|
||||||
|
--cli-pill-track: color-mix(in srgb, var(--text-primary) 10%, var(--surface-panel));
|
||||||
|
--cli-pill-fill: color-mix(in srgb, var(--accent-primary) 34%, var(--surface-panel));
|
||||||
|
padding: 1px 6px;
|
||||||
|
border-radius: 3px;
|
||||||
|
background: linear-gradient(
|
||||||
|
to right,
|
||||||
|
var(--cli-pill-fill) 0%,
|
||||||
|
var(--cli-pill-fill) var(--cli-pill-pct, 0%),
|
||||||
|
var(--cli-pill-track) var(--cli-pill-pct, 0%),
|
||||||
|
var(--cli-pill-track) 100%
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
.cli-preview-slot.is-pill.tone-good {
|
||||||
|
--cli-pill-fill: color-mix(in srgb, var(--metric-ok) 32%, var(--surface-panel));
|
||||||
|
}
|
||||||
|
|
||||||
|
.cli-preview-slot.is-pill.tone-accent {
|
||||||
|
--cli-pill-fill: color-mix(in srgb, var(--accent-primary) 34%, var(--surface-panel));
|
||||||
|
}
|
||||||
|
|
||||||
|
.cli-preview-slot.is-pill .cli-preview-prefix {
|
||||||
|
color: color-mix(in srgb, var(--text-primary) 82%, transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.cli-preview-slot.is-pill .cli-preview-val {
|
||||||
|
color: var(--text-primary);
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
.cli-status-footer {
|
.cli-status-footer {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|||||||
@@ -103,87 +103,74 @@ function isSameList(a, b) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildCliPreviewMiniBar(pct, width = 8, emptyChar = '⢕') {
|
|
||||||
const clamped = Math.max(0, Math.min(100, Number(pct)));
|
|
||||||
let filled = Math.round((clamped / 100) * width);
|
|
||||||
if (clamped > 0 && filled === 0) filled = 1;
|
|
||||||
if (clamped < 95 && filled >= width) filled = Math.max(0, width - 1);
|
|
||||||
return {
|
|
||||||
barFilled: '█'.repeat(filled),
|
|
||||||
barEmpty: emptyChar.repeat(Math.max(0, width - filled)),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatCliPreviewSlot(slotKey, isEn) {
|
function formatCliPreviewSlot(slotKey, isEn) {
|
||||||
switch (slotKey) {
|
switch (slotKey) {
|
||||||
case 'tps':
|
case 'tps':
|
||||||
return { prefix: '', barFilled: '', barEmpty: '', text: '68.4 t/s', tone: 'good' };
|
return { prefix: '', text: '68.4 t/s', tone: 'good', pillPct: null };
|
||||||
case 'avg_tps':
|
case 'avg_tps':
|
||||||
return {
|
return {
|
||||||
prefix: '',
|
prefix: '',
|
||||||
barFilled: '',
|
|
||||||
barEmpty: '',
|
|
||||||
text: isEn ? 'avg 54.0' : '均 54.0',
|
text: isEn ? 'avg 54.0' : '均 54.0',
|
||||||
tone: 'info',
|
tone: 'info',
|
||||||
|
pillPct: null,
|
||||||
};
|
};
|
||||||
case 'ttft':
|
case 'ttft':
|
||||||
return { prefix: '', barFilled: '', barEmpty: '', text: '1.1s', tone: 'good' };
|
return { prefix: '', text: '1.1s', tone: 'good', pillPct: null };
|
||||||
case 'cost':
|
case 'cost':
|
||||||
return { prefix: '', barFilled: '', barEmpty: '', text: '$0.040', tone: 'normal' };
|
return { prefix: '', text: '$0.040', tone: 'normal', pillPct: null };
|
||||||
case 'session_cost':
|
case 'session_cost':
|
||||||
return { prefix: '', barFilled: '', barEmpty: '', text: '$0.42', tone: 'normal' };
|
return { prefix: '', text: '$0.42', tone: 'normal', pillPct: null };
|
||||||
case 'cache_hit':
|
case 'cache_hit':
|
||||||
return {
|
return {
|
||||||
prefix: '',
|
prefix: '',
|
||||||
barFilled: '',
|
|
||||||
barEmpty: '',
|
|
||||||
text: isEn ? 'cache 92%' : '缓 92%',
|
text: isEn ? 'cache 92%' : '缓 92%',
|
||||||
tone: 'good',
|
tone: 'good',
|
||||||
|
pillPct: null,
|
||||||
};
|
};
|
||||||
case 'session_tokens':
|
case 'session_tokens':
|
||||||
return { prefix: '', barFilled: '', barEmpty: '', text: '142K tok', tone: 'muted' };
|
return { prefix: '', text: '142K tok', tone: 'muted', pillPct: null };
|
||||||
case 'quota_auto':
|
case 'quota_auto':
|
||||||
return {
|
return {
|
||||||
prefix: isEn ? '5h ' : '余 ',
|
prefix: isEn ? '5h ' : '余 ',
|
||||||
...buildCliPreviewMiniBar(64, 8, '⣿'),
|
text: '64%',
|
||||||
text: ' 64%',
|
|
||||||
tone: 'good',
|
tone: 'good',
|
||||||
|
pillPct: 64,
|
||||||
};
|
};
|
||||||
case 'gemini_5h':
|
case 'gemini_5h':
|
||||||
return {
|
return {
|
||||||
prefix: 'G5h ',
|
prefix: 'G5h ',
|
||||||
...buildCliPreviewMiniBar(64, 8, '⣿'),
|
text: '64%',
|
||||||
text: ' 64%',
|
|
||||||
tone: 'good',
|
tone: 'good',
|
||||||
|
pillPct: 64,
|
||||||
};
|
};
|
||||||
case 'gemini_weekly':
|
case 'gemini_weekly':
|
||||||
return {
|
return {
|
||||||
prefix: isEn ? 'Gw ' : 'G周 ',
|
prefix: isEn ? 'Gw ' : 'G周 ',
|
||||||
...buildCliPreviewMiniBar(88, 8, '⣿'),
|
text: '88%',
|
||||||
text: ' 88%',
|
|
||||||
tone: 'good',
|
tone: 'good',
|
||||||
|
pillPct: 88,
|
||||||
};
|
};
|
||||||
case 'claude_5h':
|
case 'claude_5h':
|
||||||
return {
|
return {
|
||||||
prefix: 'C5h ',
|
prefix: 'C5h ',
|
||||||
...buildCliPreviewMiniBar(96, 8, '⣿'),
|
text: '96%',
|
||||||
text: ' 96%',
|
|
||||||
tone: 'good',
|
tone: 'good',
|
||||||
|
pillPct: 96,
|
||||||
};
|
};
|
||||||
case 'claude_weekly':
|
case 'claude_weekly':
|
||||||
return {
|
return {
|
||||||
prefix: isEn ? 'Cw ' : 'C周 ',
|
prefix: isEn ? 'Cw ' : 'C周 ',
|
||||||
...buildCliPreviewMiniBar(99, 8, '⣿'),
|
text: '99%',
|
||||||
text: ' 99%',
|
|
||||||
tone: 'good',
|
tone: 'good',
|
||||||
|
pillPct: 99,
|
||||||
};
|
};
|
||||||
case 'context':
|
case 'context':
|
||||||
default:
|
default:
|
||||||
return {
|
return {
|
||||||
prefix: isEn ? 'Ctx ' : '上下文 ',
|
prefix: isEn ? 'Ctx ' : '上下文 ',
|
||||||
...buildCliPreviewMiniBar(56),
|
text: '56%',
|
||||||
text: ' 56%',
|
|
||||||
tone: 'accent',
|
tone: 'accent',
|
||||||
|
pillPct: 56,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -503,16 +490,12 @@ export const SettingsStructureTab = defineComponent({
|
|||||||
cliPreviewChildren.push(sepEl);
|
cliPreviewChildren.push(sepEl);
|
||||||
}
|
}
|
||||||
const prefixEl = h('span', { className: 'cli-preview-prefix' });
|
const prefixEl = h('span', { className: 'cli-preview-prefix' });
|
||||||
const barFillEl = h('span', { className: 'cli-preview-bar-fill' });
|
|
||||||
const barEmptyEl = h('span', { className: 'cli-preview-bar-empty' });
|
|
||||||
const valueEl = h('span', { className: 'cli-preview-val' });
|
const valueEl = h('span', { className: 'cli-preview-val' });
|
||||||
const slotEl = h('span', { className: 'cli-preview-slot' }, [
|
const slotEl = h('span', { className: 'cli-preview-slot' }, [
|
||||||
prefixEl,
|
prefixEl,
|
||||||
barFillEl,
|
|
||||||
barEmptyEl,
|
|
||||||
valueEl,
|
valueEl,
|
||||||
]);
|
]);
|
||||||
cliPreviewSlotParts.push({ slotEl, prefixEl, barFillEl, barEmptyEl, valueEl });
|
cliPreviewSlotParts.push({ slotEl, prefixEl, valueEl });
|
||||||
cliPreviewChildren.push(slotEl);
|
cliPreviewChildren.push(slotEl);
|
||||||
}
|
}
|
||||||
const cliPreviewEl = h('div', { className: 'cli-status-preview' }, cliPreviewChildren);
|
const cliPreviewEl = h('div', { className: 'cli-status-preview' }, cliPreviewChildren);
|
||||||
@@ -645,12 +628,13 @@ export const SettingsStructureTab = defineComponent({
|
|||||||
if (sepEl) patchAttr(sepEl, 'hidden', !visible);
|
if (sepEl) patchAttr(sepEl, 'hidden', !visible);
|
||||||
if (visible) {
|
if (visible) {
|
||||||
const item = formatCliPreviewSlot(key, isEn);
|
const item = formatCliPreviewSlot(key, isEn);
|
||||||
|
const isPill = Number.isFinite(item.pillPct);
|
||||||
patchAttr(parts.slotEl, 'data-metric', key);
|
patchAttr(parts.slotEl, 'data-metric', key);
|
||||||
patchText(parts.prefixEl, item.prefix || '');
|
patchText(parts.prefixEl, item.prefix || '');
|
||||||
patchText(parts.barFillEl, item.barFilled || '');
|
|
||||||
patchText(parts.barEmptyEl, item.barEmpty || '');
|
|
||||||
patchText(parts.valueEl, item.text || '');
|
patchText(parts.valueEl, item.text || '');
|
||||||
|
patchStyleVar(parts.slotEl, '--cli-pill-pct', isPill ? `${item.pillPct}%` : '');
|
||||||
patchClasses(parts.slotEl, {
|
patchClasses(parts.slotEl, {
|
||||||
|
'is-pill': isPill,
|
||||||
'tone-good': item.tone === 'good',
|
'tone-good': item.tone === 'good',
|
||||||
'tone-info': item.tone === 'info',
|
'tone-info': item.tone === 'info',
|
||||||
'tone-accent': item.tone === 'accent',
|
'tone-accent': item.tone === 'accent',
|
||||||
|
|||||||
+35
-18
@@ -6136,6 +6136,8 @@ html[data-standalone="true"] .app-shell {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.cli-preview-slot {
|
.cli-preview-slot {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
color: var(--text-primary);
|
color: var(--text-primary);
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
@@ -6161,38 +6163,53 @@ html[data-standalone="true"] .app-shell {
|
|||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cli-preview-bar-fill {
|
|
||||||
letter-spacing: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cli-preview-bar-empty {
|
|
||||||
color: var(--text-muted);
|
|
||||||
opacity: 0.65;
|
|
||||||
letter-spacing: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cli-preview-val {
|
.cli-preview-val {
|
||||||
color: var(--text-primary);
|
color: var(--text-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.cli-preview-slot.tone-good .cli-preview-val,
|
.cli-preview-slot.tone-good .cli-preview-val {
|
||||||
.cli-preview-slot.tone-good .cli-preview-bar-fill {
|
|
||||||
color: var(--metric-ok);
|
color: var(--metric-ok);
|
||||||
}
|
}
|
||||||
|
|
||||||
.cli-preview-slot.tone-info .cli-preview-val,
|
.cli-preview-slot.tone-info .cli-preview-val {
|
||||||
.cli-preview-slot.tone-info .cli-preview-bar-fill {
|
|
||||||
color: var(--metric-info);
|
color: var(--metric-info);
|
||||||
}
|
}
|
||||||
|
|
||||||
.cli-preview-slot.tone-accent .cli-preview-bar-fill {
|
|
||||||
color: var(--accent-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.cli-preview-slot.tone-muted .cli-preview-val {
|
.cli-preview-slot.tone-muted .cli-preview-val {
|
||||||
color: var(--text-secondary);
|
color: var(--text-secondary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.cli-preview-slot.is-pill {
|
||||||
|
--cli-pill-track: color-mix(in srgb, var(--text-primary) 10%, var(--surface-panel));
|
||||||
|
--cli-pill-fill: color-mix(in srgb, var(--accent-primary) 34%, var(--surface-panel));
|
||||||
|
padding: 1px 6px;
|
||||||
|
border-radius: 3px;
|
||||||
|
background: linear-gradient(
|
||||||
|
to right,
|
||||||
|
var(--cli-pill-fill) 0%,
|
||||||
|
var(--cli-pill-fill) var(--cli-pill-pct, 0%),
|
||||||
|
var(--cli-pill-track) var(--cli-pill-pct, 0%),
|
||||||
|
var(--cli-pill-track) 100%
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
.cli-preview-slot.is-pill.tone-good {
|
||||||
|
--cli-pill-fill: color-mix(in srgb, var(--metric-ok) 32%, var(--surface-panel));
|
||||||
|
}
|
||||||
|
|
||||||
|
.cli-preview-slot.is-pill.tone-accent {
|
||||||
|
--cli-pill-fill: color-mix(in srgb, var(--accent-primary) 34%, var(--surface-panel));
|
||||||
|
}
|
||||||
|
|
||||||
|
.cli-preview-slot.is-pill .cli-preview-prefix {
|
||||||
|
color: color-mix(in srgb, var(--text-primary) 82%, transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.cli-preview-slot.is-pill .cli-preview-val {
|
||||||
|
color: var(--text-primary);
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
.cli-status-footer {
|
.cli-status-footer {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|||||||
@@ -1948,7 +1948,7 @@ test('provisions Antigravity CLI statusLine safely and renders live capsule from
|
|||||||
effort: 'high',
|
effort: 'high',
|
||||||
});
|
});
|
||||||
|
|
||||||
// Capsule formatting in NO_COLOR and 24-bit ANSI modes uses transparent background (zero 48;...m SGR)
|
// Capsule formatting: NO_COLOR renders compact plain text; 24-bit ANSI renders inline pill gauges (48;2;...m) with zero OSC
|
||||||
const plainCapsule = h.formatCliStatusLineCapsule(
|
const plainCapsule = h.formatCliStatusLineCapsule(
|
||||||
{
|
{
|
||||||
hasTelemetry: true,
|
hasTelemetry: true,
|
||||||
@@ -1966,7 +1966,7 @@ test('provisions Antigravity CLI statusLine safely and renders live capsule from
|
|||||||
color: false,
|
color: false,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
assert.equal(plainCapsule, '● 0 运行中 11.8s | 38.1 t/s | 余 █████⣿⣿⣿ 57% | 上下文 █⢕⢕⢕⢕⢕⢕⢕ 17%');
|
assert.equal(plainCapsule, '● 0 运行中 11.8s | 38.1 t/s | 余 57% | 上下文 17%');
|
||||||
|
|
||||||
const ansiCapsule = h.formatCliStatusLineCapsule(
|
const ansiCapsule = h.formatCliStatusLineCapsule(
|
||||||
{
|
{
|
||||||
@@ -1985,14 +1985,15 @@ test('provisions Antigravity CLI statusLine safely and renders live capsule from
|
|||||||
color: true,
|
color: true,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
assert.equal(/\x1b\[48;/.test(ansiCapsule), false, 'Emits zero background SGR codes');
|
assert.equal(/\x1b\[48;2;116;84;22m/.test(ansiCapsule), true, 'Emits warm amber 24-bit pill fill for warn quota/context');
|
||||||
|
assert.equal(/\x1b\[48;2;36;40;50m/.test(ansiCapsule), true, 'Emits dark slate unfilled pill track');
|
||||||
assert.equal(/\x1b\]/.test(ansiCapsule), false, 'Contains zero OSC sequences so Bubble Tea width never breaks');
|
assert.equal(/\x1b\]/.test(ansiCapsule), false, 'Contains zero OSC sequences so Bubble Tea width never breaks');
|
||||||
assert.equal(
|
assert.equal(
|
||||||
ansiCapsule.replace(/\x1b\[[0-9;]*m/g, ''),
|
ansiCapsule.replace(/\x1b\[[0-9;]*m/g, ''),
|
||||||
'● 2 运行中 · 1 子 1.3s | 68.4 t/s | 余 ██⣿⣿⣿⣿⣿⣿ 22% | 上下文 ██████⢕⢕ 75%'
|
'● 2 运行中 · 1 子 1.3s | 68.4 t/s | 余 22% | 上下文 75% '
|
||||||
);
|
);
|
||||||
|
|
||||||
// Full 3-column single-line bar with left shortcuts, centered metrics, and right mode/model/effort
|
// Full 3-column single-line bar with left shortcuts, centered pill metrics, and right mode/model/effort
|
||||||
const inlineBar120 = h.formatCliStatusLineCapsule(
|
const inlineBar120 = h.formatCliStatusLineCapsule(
|
||||||
{
|
{
|
||||||
hasTelemetry: true,
|
hasTelemetry: true,
|
||||||
@@ -2014,18 +2015,19 @@ test('provisions Antigravity CLI statusLine safely and renders live capsule from
|
|||||||
modelEffort: 'medium',
|
modelEffort: 'medium',
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
assert.equal(/\x1b\[48;/.test(inlineBar120), false, 'Inline 3-column bar has zero background SGR');
|
assert.equal(/\x1b\[48;2;24;96;68m/.test(inlineBar120), true, 'Quota normal pill uses deep emerald fill');
|
||||||
|
assert.equal(/\x1b\[48;2;36;72;128m/.test(inlineBar120), true, 'Context normal pill uses slate-blue fill');
|
||||||
const plainBar120 = inlineBar120.replace(/\x1b\[[0-9;]*m/g, '');
|
const plainBar120 = inlineBar120.replace(/\x1b\[[0-9;]*m/g, '');
|
||||||
assert.ok(plainBar120.startsWith('? for shortcuts '), 'Keeps ? for shortcuts on the left');
|
assert.ok(plainBar120.startsWith('? for shortcuts '), 'Keeps ? for shortcuts on the left');
|
||||||
assert.ok(
|
assert.ok(
|
||||||
plainBar120.includes('● 2 运行中 5.6s | 22.0 t/s | 余 ████⣿⣿⣿⣿ 54% | 上下文 █⢕⢕⢕⢕⢕⢕⢕ 2%'),
|
plainBar120.includes('● 2 运行中 5.6s | 22.0 t/s | 余 54% | 上下文 2% '),
|
||||||
'Keeps full 8-cell Braille bars and full chrome when 4 slots fit in 120 columns'
|
'Keeps compact pill gauges with right-aligned percentage and full chrome in 120 columns'
|
||||||
);
|
);
|
||||||
assert.ok(plainBar120.endsWith(' auto · Gemini 4 Hydrogen · medium'), 'Renders deduplicated mode · model · effort on the right');
|
assert.ok(plainBar120.endsWith(' auto · Gemini 4 Hydrogen · medium'), 'Renders deduplicated mode · model · effort on the right');
|
||||||
assert.equal(h.cliDisplayWidth(inlineBar120), 119, 'Fits cleanly within terminalWidth - 1 without wrapping');
|
assert.equal(h.cliDisplayWidth(inlineBar120), 119, 'Fits cleanly within terminalWidth - 1 without wrapping');
|
||||||
|
|
||||||
// Mid-width 115-column terminal steps down 8-cell bars to 5-cell bars before trimming chrome
|
// Compact 108-column terminal still fits full 3-column chrome AND pill gauges cleanly (saves ~12 cols over Braille bars)
|
||||||
const inlineBar115 = h.formatCliStatusLineCapsule(
|
const inlineBar108 = h.formatCliStatusLineCapsule(
|
||||||
{
|
{
|
||||||
hasTelemetry: true,
|
hasTelemetry: true,
|
||||||
runningCount: 2,
|
runningCount: 2,
|
||||||
@@ -2040,20 +2042,20 @@ test('provisions Antigravity CLI statusLine safely and renders live capsule from
|
|||||||
showMultiSession: true,
|
showMultiSession: true,
|
||||||
language: 'zh-CN',
|
language: 'zh-CN',
|
||||||
color: true,
|
color: true,
|
||||||
terminalWidth: 115,
|
terminalWidth: 108,
|
||||||
cycleMode: 'auto',
|
cycleMode: 'auto',
|
||||||
modelDisplayName: 'Gemini 4 Hydrogen (Medium)',
|
modelDisplayName: 'Gemini 4 Hydrogen (Medium)',
|
||||||
modelEffort: 'medium',
|
modelEffort: 'medium',
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
const plainBar115 = inlineBar115.replace(/\x1b\[[0-9;]*m/g, '');
|
const plainBar108 = inlineBar108.replace(/\x1b\[[0-9;]*m/g, '');
|
||||||
assert.ok(plainBar115.startsWith('? for shortcuts '), 'Keeps ? for shortcuts when stepping down to 5-cell bars');
|
assert.ok(plainBar108.startsWith('? for shortcuts '), 'Keeps ? for shortcuts at 108 columns');
|
||||||
assert.ok(
|
assert.ok(
|
||||||
plainBar115.includes('● 2 运行中 5.6s | 22.0 t/s | 余 ███⣿⣿ 54% | 上下文 █⢕⢕⢕⢕ 2%'),
|
plainBar108.includes('● 2 运行中 5.6s | 22.0 t/s | 余 54% | 上下文 2% '),
|
||||||
'Gracefully steps down 8-cell bars to 5-cell bars on 115-col terminal while keeping full chrome'
|
'Fits compact pill gauges and full chrome even at 108 columns'
|
||||||
);
|
);
|
||||||
assert.ok(plainBar115.endsWith(' auto · Gemini 4 Hydrogen · medium'), 'Keeps full right chrome on 115-col terminal');
|
assert.ok(plainBar108.endsWith(' auto · Gemini 4 Hydrogen · medium'), 'Keeps full right chrome at 108 columns');
|
||||||
assert.equal(h.cliDisplayWidth(inlineBar115), 114, '115-col bar fits cleanly within terminalWidth - 1');
|
assert.equal(h.cliDisplayWidth(inlineBar108), 107, '108-col bar fits cleanly within terminalWidth - 1');
|
||||||
|
|
||||||
// Narrow 80-column terminal gracefully compacts without wrapping
|
// Narrow 80-column terminal gracefully compacts without wrapping
|
||||||
const inlineBar80 = h.formatCliStatusLineCapsule(
|
const inlineBar80 = h.formatCliStatusLineCapsule(
|
||||||
@@ -2227,7 +2229,7 @@ test('provisions Antigravity CLI statusLine safely and renders live capsule from
|
|||||||
input: stdinPayload,
|
input: stdinPayload,
|
||||||
encoding: 'utf8',
|
encoding: 'utf8',
|
||||||
}).trim();
|
}).trim();
|
||||||
assert.equal(capsuleOut, '● 0 运行中 1.8s | 38.1 t/s | 余 █████⣿⣿⣿ 57% | 上下文 █⢕⢕⢕⢕⢕⢕⢕ 17%');
|
assert.equal(capsuleOut, '● 0 运行中 1.8s | 38.1 t/s | 余 57% | 上下文 17%');
|
||||||
|
|
||||||
// Full 3-column single-line E2E with terminal_width + cycle_mode + model + native stdin quota fallback
|
// Full 3-column single-line E2E with terminal_width + cycle_mode + model + native stdin quota fallback
|
||||||
const emptySnapDir = join(tempRoot, 'empty-data');
|
const emptySnapDir = join(tempRoot, 'empty-data');
|
||||||
@@ -2262,10 +2264,10 @@ test('provisions Antigravity CLI statusLine safely and renders live capsule from
|
|||||||
input: fullLineStdin,
|
input: fullLineStdin,
|
||||||
encoding: 'utf8',
|
encoding: 'utf8',
|
||||||
}).replace(/\r?\n$/, '');
|
}).replace(/\r?\n$/, '');
|
||||||
assert.equal(/\x1b\[48;/.test(fullLineOut), false, 'E2E ANSI output has zero background fill');
|
assert.equal(/\x1b\[48;2;/.test(fullLineOut), true, 'E2E ANSI output renders 24-bit pill background fill');
|
||||||
const plainFullLine = fullLineOut.replace(/\x1b\[[0-9;]*m/g, '');
|
const plainFullLine = fullLineOut.replace(/\x1b\[[0-9;]*m/g, '');
|
||||||
assert.ok(plainFullLine.startsWith('? for shortcuts '));
|
assert.ok(plainFullLine.startsWith('? for shortcuts '));
|
||||||
assert.ok(plainFullLine.includes('● 1 运行中 1.8s | 38.1 t/s | 余 ████⣿⣿⣿⣿ 54% | 上下文 █⢕⢕⢕⢕⢕⢕⢕ 2%'));
|
assert.ok(plainFullLine.includes('● 1 运行中 1.8s | 38.1 t/s | 余 54% | 上下文 2% '));
|
||||||
assert.ok(plainFullLine.endsWith(' auto · Gemini 4 Hydrogen · medium'));
|
assert.ok(plainFullLine.endsWith(' auto · Gemini 4 Hydrogen · medium'));
|
||||||
assert.equal(h.cliDisplayWidth(fullLineOut), 129);
|
assert.equal(h.cliDisplayWidth(fullLineOut), 129);
|
||||||
|
|
||||||
@@ -2276,7 +2278,7 @@ test('provisions Antigravity CLI statusLine safely and renders live capsule from
|
|||||||
input: stdinPayload,
|
input: stdinPayload,
|
||||||
encoding: 'utf8',
|
encoding: 'utf8',
|
||||||
}).trim();
|
}).trim();
|
||||||
assert.equal(cmdCapsuleOut, '● 0 运行中 1.8s | 38.1 t/s | 余 █████⣿⣿⣿ 57% | 上下文 █⢕⢕⢕⢕⢕⢕⢕ 17%');
|
assert.equal(cmdCapsuleOut, '● 0 运行中 1.8s | 38.1 t/s | 余 57% | 上下文 17%');
|
||||||
|
|
||||||
const spaceDir = join(tempRoot, 'Dir With Spaces');
|
const spaceDir = join(tempRoot, 'Dir With Spaces');
|
||||||
mkdirSync(spaceDir, { recursive: true });
|
mkdirSync(spaceDir, { recursive: true });
|
||||||
@@ -2292,7 +2294,7 @@ test('provisions Antigravity CLI statusLine safely and renders live capsule from
|
|||||||
input: stdinPayload,
|
input: stdinPayload,
|
||||||
encoding: 'utf8',
|
encoding: 'utf8',
|
||||||
}).trim();
|
}).trim();
|
||||||
assert.equal(autorunOut, '● 0 运行中 1.8s | 38.1 t/s | 余 █████⣿⣿⣿ 57% | 上下文 █⢕⢕⢕⢕⢕⢕⢕ 17%');
|
assert.equal(autorunOut, '● 0 运行中 1.8s | 38.1 t/s | 余 57% | 上下文 17%');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify compaction-line precedence: when local trajectory reports maxContextTokens (e.g. 512k),
|
// Verify compaction-line precedence: when local trajectory reports maxContextTokens (e.g. 512k),
|
||||||
@@ -2355,10 +2357,17 @@ test('provisions Antigravity CLI statusLine safely and renders live capsule from
|
|||||||
encoding: 'utf8',
|
encoding: 'utf8',
|
||||||
}).trim();
|
}).trim();
|
||||||
assert.ok(
|
assert.ok(
|
||||||
limitOut.includes('上下文 ███████⢕ 92%'),
|
limitOut.includes('上下文 92%'),
|
||||||
`expected compaction-limit 92% instead of physical 42%, got: ${limitOut}`
|
`expected compaction-limit 92% instead of physical 42%, got: ${limitOut}`
|
||||||
);
|
);
|
||||||
assert.equal(limitOut.includes('42%'), false);
|
assert.equal(limitOut.includes('42%'), false);
|
||||||
|
const limitAnsiOut = execFileSync(process.execPath, [statusLineScript], {
|
||||||
|
env: installEnv,
|
||||||
|
input: limitStdin,
|
||||||
|
encoding: 'utf8',
|
||||||
|
}).trim();
|
||||||
|
assert.equal(/\x1b\[48;2;124;42;48m/.test(limitAnsiOut), true, '92% compaction limit uses danger crimson pill');
|
||||||
|
assert.ok(limitAnsiOut.replace(/\x1b\[[0-9;]*m/g, '').includes(' 上下文 92% '));
|
||||||
|
|
||||||
// Verify real non-test.invalid buildTelemetryPayload writes cli-status-snapshot.json cleanly without throwing
|
// Verify real non-test.invalid buildTelemetryPayload writes cli-status-snapshot.json cleanly without throwing
|
||||||
const builderUrl = new URL('../backend/telemetry-builder.mjs', import.meta.url).href;
|
const builderUrl = new URL('../backend/telemetry-builder.mjs', import.meta.url).href;
|
||||||
@@ -2508,9 +2517,9 @@ test('CLI statusLine v1.5.4 upgrades: /statusline inline flags, preserved manage
|
|||||||
color: false,
|
color: false,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
assert.equal(freshBar, '● 0 运行中 空闲 | 余 ████████ 98% | 上下文 █⢕⢕⢕⢕⢕⢕⢕ 16%');
|
assert.equal(freshBar, '● 0 运行中 空闲 | 余 98% | 上下文 16%');
|
||||||
|
|
||||||
// 5b. Dedicated 5h / weekly / context 8-cell mini progress bars in zh-CN & en-US
|
// 5b. Dedicated 5h / weekly / context slots in NO_COLOR and pill ANSI modes (zh-CN & en-US)
|
||||||
const quotaBarCtx = {
|
const quotaBarCtx = {
|
||||||
hasTelemetry: true,
|
hasTelemetry: true,
|
||||||
stepCount: 3,
|
stepCount: 3,
|
||||||
@@ -2529,7 +2538,20 @@ test('CLI statusLine v1.5.4 upgrades: /statusline inline flags, preserved manage
|
|||||||
language: 'zh-CN',
|
language: 'zh-CN',
|
||||||
color: false,
|
color: false,
|
||||||
}),
|
}),
|
||||||
'G5h █████⣿⣿⣿ 64% | G周 ███████⣿ 88% | C5h ████████ 96% | C周 █⣿⣿⣿⣿⣿⣿⣿ 14% | 上下文 ████⢕⢕⢕⢕ 56%'
|
'G5h 64% | G周 88% | C5h 96% | C周 14% | 上下文 56%'
|
||||||
|
);
|
||||||
|
const quotaPillAnsi = h.formatCliStatusLineCapsule(quotaBarCtx, {
|
||||||
|
slots: ['gemini_5h', 'claude_weekly', 'context'],
|
||||||
|
showMultiSession: false,
|
||||||
|
language: 'zh-CN',
|
||||||
|
color: true,
|
||||||
|
});
|
||||||
|
assert.equal(/\x1b\[48;2;24;96;68m/.test(quotaPillAnsi), true, '64% quota uses green pill fill');
|
||||||
|
assert.equal(/\x1b\[48;2;124;42;48m/.test(quotaPillAnsi), true, '14% quota uses danger red pill fill');
|
||||||
|
assert.equal(/\x1b\[48;2;36;72;128m/.test(quotaPillAnsi), true, '56% context uses blue pill fill');
|
||||||
|
assert.equal(
|
||||||
|
quotaPillAnsi.replace(/\x1b\[[0-9;]*m/g, ''),
|
||||||
|
' G5h 64% | C周 14% | 上下文 56% '
|
||||||
);
|
);
|
||||||
assert.equal(
|
assert.equal(
|
||||||
h.formatCliStatusLineCapsule(quotaBarCtx, {
|
h.formatCliStatusLineCapsule(quotaBarCtx, {
|
||||||
@@ -2538,7 +2560,7 @@ test('CLI statusLine v1.5.4 upgrades: /statusline inline flags, preserved manage
|
|||||||
language: 'en-US',
|
language: 'en-US',
|
||||||
color: false,
|
color: false,
|
||||||
}),
|
}),
|
||||||
'Gw ███████⣿ 88% | Cw █⣿⣿⣿⣿⣿⣿⣿ 14% | Ctx ████⢕⢕⢕⢕ 56%'
|
'Gw 88% | Cw 14% | Ctx 56%'
|
||||||
);
|
);
|
||||||
|
|
||||||
// 5c. Local SQLite WAITING step immediately turns CLI dot amber even while Desktop snapshot is still false
|
// 5c. Local SQLite WAITING step immediately turns CLI dot amber even while Desktop snapshot is still false
|
||||||
@@ -2592,7 +2614,7 @@ test('CLI statusLine v1.5.4 upgrades: /statusline inline flags, preserved manage
|
|||||||
});
|
});
|
||||||
assert.equal(resumedFromLocalDb.hasWaiting, false);
|
assert.equal(resumedFromLocalDb.hasWaiting, false);
|
||||||
|
|
||||||
// 6. Anomaly badge (toggleable via showAnomaly) + zero background SGR / OSC
|
// 6. Anomaly badge (toggleable via showAnomaly) + pill SGR & zero OSC
|
||||||
const withAnom = h.formatCliStatusLineCapsule(
|
const withAnom = h.formatCliStatusLineCapsule(
|
||||||
{
|
{
|
||||||
hasTelemetry: true,
|
hasTelemetry: true,
|
||||||
@@ -2609,9 +2631,9 @@ test('CLI statusLine v1.5.4 upgrades: /statusline inline flags, preserved manage
|
|||||||
color: true,
|
color: true,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
assert.equal(/\x1b\[48;/.test(withAnom), false);
|
assert.equal(/\x1b\[48;2;36;72;128m/.test(withAnom), true);
|
||||||
assert.equal(/\x1b\]/.test(withAnom), false);
|
assert.equal(/\x1b\]/.test(withAnom), false);
|
||||||
assert.equal(withAnom.replace(/\x1b\[[0-9;]*m/g, ''), '● 1 运行中 44.2 t/s | 2.1s | 上下文 ███⢕⢕⢕⢕⢕ 35% | ! 503');
|
assert.equal(withAnom.replace(/\x1b\[[0-9;]*m/g, ''), '● 1 运行中 44.2 t/s | 2.1s | 上下文 35% | ! 503');
|
||||||
|
|
||||||
const withoutAnom = h.formatCliStatusLineCapsule(
|
const withoutAnom = h.formatCliStatusLineCapsule(
|
||||||
{
|
{
|
||||||
@@ -2630,7 +2652,7 @@ test('CLI statusLine v1.5.4 upgrades: /statusline inline flags, preserved manage
|
|||||||
color: false,
|
color: false,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
assert.equal(withoutAnom, '● 1 运行中 44.2 t/s | 2.1s | 上下文 ███⢕⢕⢕⢕⢕ 35%');
|
assert.equal(withoutAnom, '● 1 运行中 44.2 t/s | 2.1s | 上下文 35%');
|
||||||
|
|
||||||
// 7. Narrow 72-column terminal progressively sheds lower-priority slots without wrapping
|
// 7. Narrow 72-column terminal progressively sheds lower-priority slots without wrapping
|
||||||
const narrow72 = h.formatCliStatusLineCapsule(
|
const narrow72 = h.formatCliStatusLineCapsule(
|
||||||
@@ -2707,7 +2729,7 @@ test('CLI statusLine v1.5.4 upgrades: /statusline inline flags, preserved manage
|
|||||||
encoding: 'utf8',
|
encoding: 'utf8',
|
||||||
}
|
}
|
||||||
).trim();
|
).trim();
|
||||||
assert.equal(inlineOut, 'Idle | 5h ███████⣿ 91% | Ctx ██⢕⢕⢕⢕⢕⢕ 19%');
|
assert.equal(inlineOut, 'Idle | 5h 91% | Ctx 19%');
|
||||||
|
|
||||||
// 9. Runtime CLI installation & status detection (strictly gated on antigravity-cli dir) + forceReplaceCustom recovery
|
// 9. Runtime CLI installation & status detection (strictly gated on antigravity-cli dir) + forceReplaceCustom recovery
|
||||||
const { ensureCliStatusLineConfigured, getCliStatusLineRuntimeStatus } = await import(
|
const { ensureCliStatusLineConfigured, getCliStatusLineRuntimeStatus } = await import(
|
||||||
|
|||||||
@@ -5927,9 +5927,13 @@ test('SettingsStructureTab CLI statusLine controls stay hidden unless CLI is det
|
|||||||
.querySelectorAll('.cli-preview-slot')
|
.querySelectorAll('.cli-preview-slot')
|
||||||
.filter((el) => !el.hasAttribute('hidden'))
|
.filter((el) => !el.hasAttribute('hidden'))
|
||||||
.map((el) => el.textContent);
|
.map((el) => el.textContent);
|
||||||
assert.deepEqual(visibleSlots(), ['68.4 t/s', '1.1s', '$0.42', '余 █████⣿⣿⣿ 64%', '上下文 ████⢕⢕⢕⢕ 56%']);
|
assert.deepEqual(visibleSlots(), ['68.4 t/s', '1.1s', '$0.42', '余 64%', '上下文 56%']);
|
||||||
|
const pillSlots1 = previewEl
|
||||||
|
.querySelectorAll('.cli-preview-slot.is-pill')
|
||||||
|
.filter((el) => !el.hasAttribute('hidden'));
|
||||||
|
assert.equal(pillSlots1.length, 2, 'Quota and context slots render as background-filled pills');
|
||||||
|
|
||||||
// 3. Dedicated 5h / weekly / context slots render distinct mini progress bars in live preview
|
// 3. Dedicated 5h / weekly / context slots render distinct pill gauges in live preview
|
||||||
strTab.refs.renderSettings(
|
strTab.refs.renderSettings(
|
||||||
{
|
{
|
||||||
enableCliStatusLine: true,
|
enableCliStatusLine: true,
|
||||||
@@ -5940,12 +5944,16 @@ test('SettingsStructureTab CLI statusLine controls stay hidden unless CLI is det
|
|||||||
{ installed: true, configured: true, preservedCustom: false, managedFlags: '' }
|
{ installed: true, configured: true, preservedCustom: false, managedFlags: '' }
|
||||||
);
|
);
|
||||||
assert.deepEqual(visibleSlots(), [
|
assert.deepEqual(visibleSlots(), [
|
||||||
'G5h █████⣿⣿⣿ 64%',
|
'G5h 64%',
|
||||||
'G周 ███████⣿ 88%',
|
'G周 88%',
|
||||||
'C5h ████████ 96%',
|
'C5h 96%',
|
||||||
'C周 ████████ 99%',
|
'C周 99%',
|
||||||
'上下文 ████⢕⢕⢕⢕ 56%',
|
'上下文 56%',
|
||||||
]);
|
]);
|
||||||
|
const pillSlots2 = previewEl
|
||||||
|
.querySelectorAll('.cli-preview-slot.is-pill')
|
||||||
|
.filter((el) => !el.hasAttribute('hidden'));
|
||||||
|
assert.equal(pillSlots2.length, 5);
|
||||||
|
|
||||||
// 4. Turning CLI statusLine off collapses detail panel
|
// 4. Turning CLI statusLine off collapses detail panel
|
||||||
strTab.refs.renderSettings(
|
strTab.refs.renderSettings(
|
||||||
|
|||||||
Reference in New Issue
Block a user