mirror of
https://github.com/lWolvesl/antigravity-usage-monitor.git
synced 2026-11-26 17:09:28 +08:00
feat(cli): upgrade statusLine with Braille progress bars, instant waiting sync, /statusline flags, and CLI-gated settings
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
import {
|
||||
normalizeCliStatusLineSlots,
|
||||
normalizeFontScale,
|
||||
normalizeHoverModules,
|
||||
normalizeLanguageSetting,
|
||||
@@ -104,6 +105,7 @@ export function buildExportableSettingsJson(settings = {}) {
|
||||
popoverWidthMode: normalizePopoverWidthMode(src.popoverWidthMode),
|
||||
popoverWidth: normalizePopoverWidth(src.popoverWidth),
|
||||
enableCliStatusLine: src.enableCliStatusLine !== false,
|
||||
cliStatusLineSlots: normalizeCliStatusLineSlots(src.cliStatusLineSlots),
|
||||
standalonePort: normalizeStandalonePort(src.standalonePort),
|
||||
showTopbarMultiSession: src.showTopbarMultiSession !== false,
|
||||
topbarCapsuleSlots: normalizeTopbarCapsuleSlots(src.topbarCapsuleSlots),
|
||||
@@ -195,6 +197,9 @@ export function parseImportedSettingsJson(rawText) {
|
||||
if (hasKey('enableCliStatusLine') && typeof src.enableCliStatusLine === 'boolean') {
|
||||
patch.enableCliStatusLine = src.enableCliStatusLine;
|
||||
}
|
||||
if (hasKey('cliStatusLineSlots')) {
|
||||
patch.cliStatusLineSlots = normalizeCliStatusLineSlots(src.cliStatusLineSlots);
|
||||
}
|
||||
if (hasKey('standalonePort')) {
|
||||
patch.standalonePort = normalizeStandalonePort(src.standalonePort);
|
||||
}
|
||||
|
||||
@@ -559,6 +559,16 @@ export const I18N_MESSAGES_EN_US = Object.freeze({
|
||||
'settings.str.popoverWidthHint': 'Auto Fit widens wide tables like Step Records to avoid horizontal scroll; Custom accepts 440–1080 px',
|
||||
'settings.str.multiToggle': 'Active Sessions Pill',
|
||||
'settings.str.cliCapsuleToggle': 'CLI Bottom Capsule',
|
||||
'settings.str.cliSlotsLabel': 'CLI Slot Order (Left → Right, 1–6, draggable)',
|
||||
'settings.str.addCliSlot': 'Add CLI Slot ({count}/{max})',
|
||||
'settings.str.cliCustomCmdHint': 'Custom statusLine command detected; preserved automatically unless you take over',
|
||||
'settings.str.cliPausedHint': 'CLI statusLine is currently paused or not yet configured',
|
||||
'settings.str.cliFlagsOverrideHint': 'Explicit CLI launch flags (--slots / --preset) detected and take precedence over these slots',
|
||||
'settings.str.cliRestoreBtn': 'Take Over & Restore',
|
||||
'settings.str.cliEnableBtn': 'Re-enable in CLI',
|
||||
'settings.str.cliClearFlagsBtn': 'Clear Flag Override',
|
||||
'settings.str.cliRestoringBtn': 'Applying...',
|
||||
'settings.str.cliPreviewRunning': '{count} active',
|
||||
'settings.str.show': 'Show',
|
||||
'settings.str.hide': 'Hide',
|
||||
'settings.str.on': 'On',
|
||||
|
||||
@@ -559,6 +559,16 @@ export const I18N_MESSAGES_ZH_CN = Object.freeze({
|
||||
'settings.str.popoverWidthHint': '自适应模式下在调用明细等宽表格视图自动撑宽免水平滚动;指定宽度范围 440~1080 px',
|
||||
'settings.str.multiToggle': '实时运行会话入口',
|
||||
'settings.str.cliCapsuleToggle': 'CLI 底部状态胶囊',
|
||||
'settings.str.cliSlotsLabel': 'CLI 槽位顺序 (左 → 右,1~6 项,可拖拽)',
|
||||
'settings.str.addCliSlot': '添加 CLI 槽位 ({count}/{max})',
|
||||
'settings.str.cliCustomCmdHint': '检测到自定义 statusLine 命令,为避免误覆盖默认不会自动改写',
|
||||
'settings.str.cliPausedHint': 'CLI 端当前已暂停或未写入 statusLine 配置',
|
||||
'settings.str.cliFlagsOverrideHint': '检测到 CLI 启动参数包含显式槽位覆盖,命令行参数将优先于此处配置',
|
||||
'settings.str.cliRestoreBtn': '一键接管并恢复',
|
||||
'settings.str.cliEnableBtn': '重新写入并启用',
|
||||
'settings.str.cliClearFlagsBtn': '清除命令行覆盖',
|
||||
'settings.str.cliRestoringBtn': '正在写入...',
|
||||
'settings.str.cliPreviewRunning': '{count} 运行中',
|
||||
'settings.str.show': '显示',
|
||||
'settings.str.hide': '隐藏',
|
||||
'settings.str.on': '开启',
|
||||
|
||||
@@ -26,6 +26,8 @@ import {
|
||||
resolveSettingsModernUi,
|
||||
} from '../core/appearance.js';
|
||||
import {
|
||||
CLI_STATUSLINE_PRESETS,
|
||||
DEFAULT_CLI_STATUSLINE_SLOTS,
|
||||
DEFAULT_HOVER_MODULES,
|
||||
DEFAULT_OVERVIEW_METRICS,
|
||||
DEFAULT_OVERVIEW_MODULES,
|
||||
@@ -39,6 +41,7 @@ import {
|
||||
OVERVIEW_MODULE_KEYS,
|
||||
STEP_TABLE_COLUMN_KEYS,
|
||||
TOPBAR_SLOT_KEYS,
|
||||
normalizeCliStatusLineSlots,
|
||||
normalizeHoverModules,
|
||||
normalizeModelDisplayMode,
|
||||
normalizeOrchestratorIdMode,
|
||||
@@ -53,6 +56,7 @@ import {
|
||||
normalizeWeeklyLimitMode,
|
||||
normalizeWindowMountMode,
|
||||
parseStepTokenComboSegments,
|
||||
resolveEffectiveCliStatusLineSlots,
|
||||
} from '../../shared/settings-normalization.mjs';
|
||||
import {
|
||||
LOCAL_ENDPOINT_ID,
|
||||
@@ -438,6 +442,8 @@ function reconcileIncomingTelemetrySettings(payload, reqSettingsRev) {
|
||||
|
||||
export const CLIENT_TOPBAR_SLOT_KEYS = TOPBAR_SLOT_KEYS;
|
||||
export const DEFAULT_CLIENT_TOPBAR_SLOTS = DEFAULT_TOPBAR_SLOTS;
|
||||
export const CLIENT_CLI_STATUSLINE_PRESETS = CLI_STATUSLINE_PRESETS;
|
||||
export const DEFAULT_CLIENT_CLI_STATUSLINE_SLOTS = DEFAULT_CLI_STATUSLINE_SLOTS;
|
||||
export const CLIENT_OVERVIEW_MODULE_KEYS = OVERVIEW_MODULE_KEYS;
|
||||
export const DEFAULT_CLIENT_OVERVIEW_MODULES = DEFAULT_OVERVIEW_MODULES;
|
||||
export const DEFAULT_CLIENT_HOVER_MODULES = DEFAULT_HOVER_MODULES;
|
||||
@@ -456,6 +462,8 @@ export const normalizeClientPopoverWidthMode = normalizePopoverWidthMode;
|
||||
export const normalizeClientPopoverWidth = normalizePopoverWidth;
|
||||
export const normalizeClientModelDisplayMode = normalizeModelDisplayMode;
|
||||
export const normalizeClientTopbarSlots = normalizeTopbarCapsuleSlots;
|
||||
export const normalizeClientCliStatusLineSlots = normalizeCliStatusLineSlots;
|
||||
export const resolveEffectiveClientCliStatusLineSlots = resolveEffectiveCliStatusLineSlots;
|
||||
export const normalizeClientHoverModules = normalizeHoverModules;
|
||||
export const normalizeClientOverviewModules = normalizeOverviewModules;
|
||||
export const normalizeClientOverviewMetrics = normalizeOverviewMetrics;
|
||||
@@ -544,6 +552,7 @@ export function isEquivalentTelemetry(prev, next) {
|
||||
if ((pSet?.enableCliStatusLine !== false) !== (nSet?.enableCliStatusLine !== false)) {
|
||||
return false;
|
||||
}
|
||||
if (!sameArr(pSet?.cliStatusLineSlots, nSet?.cliStatusLineSlots)) return false;
|
||||
if ((pSet?.showTopbarMultiSession !== false) !== (nSet?.showTopbarMultiSession !== false)) {
|
||||
return false;
|
||||
}
|
||||
@@ -575,6 +584,16 @@ export function isEquivalentTelemetry(prev, next) {
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
const pCli = prev.cliStatusLine;
|
||||
const nCli = next.cliStatusLine;
|
||||
if (
|
||||
Boolean(pCli?.installed) !== Boolean(nCli?.installed) ||
|
||||
Boolean(pCli?.configured) !== Boolean(nCli?.configured) ||
|
||||
Boolean(pCli?.preservedCustom) !== Boolean(nCli?.preservedCustom) ||
|
||||
String(pCli?.managedFlags || '') !== String(nCli?.managedFlags || '')
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
const pCloud = prev.cloudStatus;
|
||||
const nCloud = next.cloudStatus;
|
||||
if (
|
||||
@@ -1712,6 +1731,9 @@ export async function saveSettingsPatch(patch) {
|
||||
if (Object.prototype.hasOwnProperty.call(safePatch, 'topbarCapsuleSlots')) {
|
||||
safePatch.topbarCapsuleSlots = normalizeClientTopbarSlots(safePatch.topbarCapsuleSlots);
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(safePatch, 'cliStatusLineSlots')) {
|
||||
safePatch.cliStatusLineSlots = normalizeClientCliStatusLineSlots(safePatch.cliStatusLineSlots);
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(safePatch, 'hoverModules')) {
|
||||
safePatch.hoverModules = normalizeClientHoverModules(safePatch.hoverModules);
|
||||
}
|
||||
@@ -1957,6 +1979,24 @@ export async function triggerBridgeHostRelaunch() {
|
||||
}
|
||||
}
|
||||
|
||||
export async function triggerCliStatusLineAction(action) {
|
||||
const res = await callSidecarApi('/api/settings', {
|
||||
method: 'POST',
|
||||
body: { __cliStatusLineAction: String(action || 'force_install') },
|
||||
});
|
||||
const cur = telemetryStore.getState().telemetry;
|
||||
if (cur && res && typeof res === 'object') {
|
||||
const nextTelemetry = {
|
||||
...cur,
|
||||
...(res.cliStatusLine ? { cliStatusLine: res.cliStatusLine } : {}),
|
||||
...(res.settings ? { settings: { ...cur.settings, ...res.settings } } : {}),
|
||||
};
|
||||
telemetryStore.setState({ telemetry: nextTelemetry });
|
||||
}
|
||||
void fetchTelemetry({ force: true }).catch(() => {});
|
||||
return res;
|
||||
}
|
||||
|
||||
export async function triggerPluginUpdate() {
|
||||
const res = await callSidecarApi('/api/plugin-update', { method: 'POST', body: {} });
|
||||
if (res?.ok && res?.restarting) {
|
||||
|
||||
@@ -995,3 +995,180 @@
|
||||
.settings-hidden-file-input {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
/* --- Antigravity CLI 底部状态胶囊专属配置块(仅检测到 CLI 时展示) --- */
|
||||
.cli-statusline-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-3);
|
||||
}
|
||||
|
||||
.cli-statusline-group[hidden],
|
||||
.cli-statusline-detail[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.cli-statusline-detail {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-3);
|
||||
}
|
||||
|
||||
.cli-status-preview {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: nowrap;
|
||||
gap: 0;
|
||||
min-height: 30px;
|
||||
padding: 5px 10px;
|
||||
border-radius: var(--radius-xs);
|
||||
border: 1px solid var(--border-hairline);
|
||||
background: var(--surface-bg);
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--fs-sm);
|
||||
font-variant-numeric: tabular-nums;
|
||||
line-height: 1.3;
|
||||
white-space: nowrap;
|
||||
overflow-x: auto;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.cli-preview-multi {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
margin-right: 12px;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.cli-preview-multi[hidden],
|
||||
.cli-preview-slot[hidden],
|
||||
.cli-preview-sep[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.cli-preview-dot {
|
||||
color: var(--metric-good);
|
||||
font-size: var(--fs-xs);
|
||||
}
|
||||
|
||||
.cli-preview-sep {
|
||||
margin: 0 7px;
|
||||
color: var(--text-muted);
|
||||
opacity: 0.72;
|
||||
}
|
||||
|
||||
.cli-preview-slot {
|
||||
color: var(--text-primary);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.cli-preview-slot.tone-good {
|
||||
color: var(--metric-good);
|
||||
}
|
||||
|
||||
.cli-preview-slot.tone-info {
|
||||
color: var(--metric-info);
|
||||
}
|
||||
|
||||
.cli-preview-slot.tone-accent {
|
||||
color: var(--accent-primary);
|
||||
}
|
||||
|
||||
.cli-preview-slot.tone-muted {
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.cli-preview-prefix {
|
||||
color: var(--text-secondary);
|
||||
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 {
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.cli-preview-slot.tone-good .cli-preview-val,
|
||||
.cli-preview-slot.tone-good .cli-preview-bar-fill {
|
||||
color: var(--metric-good);
|
||||
}
|
||||
|
||||
.cli-preview-slot.tone-info .cli-preview-val,
|
||||
.cli-preview-slot.tone-info .cli-preview-bar-fill {
|
||||
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 {
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.cli-status-footer {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.cli-status-footer[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.cli-status-hint.is-warn {
|
||||
color: var(--metric-warn);
|
||||
}
|
||||
|
||||
.cli-status-action-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: calc(24px * var(--ui-font-scale, 1));
|
||||
padding: 2px 10px;
|
||||
border-radius: var(--radius-xs);
|
||||
border: 1px solid var(--accent-primary-border);
|
||||
background: var(--accent-primary-soft);
|
||||
color: var(--accent-primary);
|
||||
font-size: var(--fs-sm);
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
white-space: nowrap;
|
||||
transition:
|
||||
background-color var(--dur-instant) var(--ease-fast),
|
||||
opacity var(--dur-instant) var(--ease-fast);
|
||||
}
|
||||
|
||||
.cli-status-action-btn:hover:not(:disabled) {
|
||||
background: color-mix(in srgb, var(--accent-primary) 20%, transparent);
|
||||
}
|
||||
|
||||
.cli-status-action-btn.is-warn {
|
||||
border-color: color-mix(in srgb, var(--metric-warn) 48%, var(--border-hairline));
|
||||
background: color-mix(in srgb, var(--metric-warn) 14%, transparent);
|
||||
color: var(--metric-warn);
|
||||
}
|
||||
|
||||
.cli-status-action-btn.is-warn:hover:not(:disabled) {
|
||||
background: color-mix(in srgb, var(--metric-warn) 22%, transparent);
|
||||
}
|
||||
|
||||
.cli-status-action-btn:disabled {
|
||||
opacity: 0.65;
|
||||
cursor: wait;
|
||||
}
|
||||
|
||||
.cli-status-action-btn[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
@@ -107,7 +107,8 @@ export const SettingsView = defineComponent({
|
||||
structureTab.refs.renderSettings(
|
||||
settings,
|
||||
telemetry?.windowBridge,
|
||||
telemetry?.hostPlatform
|
||||
telemetry?.hostPlatform,
|
||||
telemetry?.cliStatusLine
|
||||
);
|
||||
}
|
||||
} else if (settingsSubTab === 'other') {
|
||||
@@ -132,6 +133,7 @@ export const SettingsView = defineComponent({
|
||||
(st) => ({
|
||||
settings: st.telemetry?.settings,
|
||||
windowBridge: st.telemetry?.windowBridge,
|
||||
cliStatusLine: st.telemetry?.cliStatusLine,
|
||||
hostPlatform: st.telemetry?.hostPlatform,
|
||||
cloudStatus: st.telemetry?.cloudStatus,
|
||||
contextWindowModels: st.telemetry?.contextWindowModels,
|
||||
|
||||
@@ -29,6 +29,7 @@ import {
|
||||
DEFAULT_CLIENT_TOPBAR_SLOTS,
|
||||
MAX_CLIENT_POPOVER_WIDTH,
|
||||
MIN_CLIENT_POPOVER_WIDTH,
|
||||
normalizeClientCliStatusLineSlots,
|
||||
normalizeClientHoverModules,
|
||||
normalizeClientOverviewMetrics,
|
||||
normalizeClientOverviewModules,
|
||||
@@ -38,7 +39,9 @@ import {
|
||||
normalizeClientStepTokenComboFormat,
|
||||
normalizeClientTopbarSlots,
|
||||
normalizeClientWindowMountMode,
|
||||
resolveEffectiveClientCliStatusLineSlots,
|
||||
saveSettingsPatch,
|
||||
triggerCliStatusLineAction,
|
||||
} from '../../store/telemetryStore.js';
|
||||
import { getVisibleMonitorView, uiStore } from '../../store/uiStore.js';
|
||||
import { BridgeStatusNotice } from '../../components/settings/BridgeStatusNotice.js';
|
||||
@@ -100,6 +103,91 @@ function isSameList(a, b) {
|
||||
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) {
|
||||
switch (slotKey) {
|
||||
case 'tps':
|
||||
return { prefix: '', barFilled: '', barEmpty: '', text: '68.4 t/s', tone: 'good' };
|
||||
case 'avg_tps':
|
||||
return {
|
||||
prefix: '',
|
||||
barFilled: '',
|
||||
barEmpty: '',
|
||||
text: isEn ? 'avg 54.0' : '均 54.0',
|
||||
tone: 'info',
|
||||
};
|
||||
case 'ttft':
|
||||
return { prefix: '', barFilled: '', barEmpty: '', text: '1.1s', tone: 'good' };
|
||||
case 'cost':
|
||||
return { prefix: '', barFilled: '', barEmpty: '', text: '$0.040', tone: 'normal' };
|
||||
case 'session_cost':
|
||||
return { prefix: '', barFilled: '', barEmpty: '', text: '$0.42', tone: 'normal' };
|
||||
case 'cache_hit':
|
||||
return {
|
||||
prefix: '',
|
||||
barFilled: '',
|
||||
barEmpty: '',
|
||||
text: isEn ? 'cache 92%' : '缓 92%',
|
||||
tone: 'good',
|
||||
};
|
||||
case 'session_tokens':
|
||||
return { prefix: '', barFilled: '', barEmpty: '', text: '142K tok', tone: 'muted' };
|
||||
case 'quota_auto':
|
||||
return {
|
||||
prefix: isEn ? '5h ' : '余 ',
|
||||
...buildCliPreviewMiniBar(64, 8, '⣿'),
|
||||
text: ' 64%',
|
||||
tone: 'good',
|
||||
};
|
||||
case 'gemini_5h':
|
||||
return {
|
||||
prefix: 'G5h ',
|
||||
...buildCliPreviewMiniBar(64, 8, '⣿'),
|
||||
text: ' 64%',
|
||||
tone: 'good',
|
||||
};
|
||||
case 'gemini_weekly':
|
||||
return {
|
||||
prefix: isEn ? 'Gw ' : 'G周 ',
|
||||
...buildCliPreviewMiniBar(88, 8, '⣿'),
|
||||
text: ' 88%',
|
||||
tone: 'good',
|
||||
};
|
||||
case 'claude_5h':
|
||||
return {
|
||||
prefix: 'C5h ',
|
||||
...buildCliPreviewMiniBar(96, 8, '⣿'),
|
||||
text: ' 96%',
|
||||
tone: 'good',
|
||||
};
|
||||
case 'claude_weekly':
|
||||
return {
|
||||
prefix: isEn ? 'Cw ' : 'C周 ',
|
||||
...buildCliPreviewMiniBar(99, 8, '⣿'),
|
||||
text: ' 99%',
|
||||
tone: 'good',
|
||||
};
|
||||
case 'context':
|
||||
default:
|
||||
return {
|
||||
prefix: isEn ? 'Ctx ' : '上下文 ',
|
||||
...buildCliPreviewMiniBar(56),
|
||||
text: ' 56%',
|
||||
tone: 'accent',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export const SettingsStructureTab = defineComponent({
|
||||
name: 'SettingsStructureTab',
|
||||
setup({ props, onCleanup }) {
|
||||
@@ -108,6 +196,7 @@ export const SettingsStructureTab = defineComponent({
|
||||
let draftPopoverWidthMode = 'auto';
|
||||
let draftPopoverWidth = DEFAULT_CLIENT_POPOVER_WIDTH;
|
||||
let draftEnableCliStatusLine = true;
|
||||
let draftCliStatusLineSlots = null;
|
||||
let draftShowTopbarMulti = true;
|
||||
let draftTopbarSlots = [...DEFAULT_CLIENT_TOPBAR_SLOTS];
|
||||
let draftHoverModules = [...DEFAULT_CLIENT_HOVER_MODULES];
|
||||
@@ -121,8 +210,16 @@ export const SettingsStructureTab = defineComponent({
|
||||
let draftStepColumns = [...DEFAULT_CLIENT_STEP_COLUMNS];
|
||||
let latestSettings = null;
|
||||
let latestWindowBridge = null;
|
||||
let latestCliStatusLine = null;
|
||||
let latestHostPlatform = 'win32';
|
||||
|
||||
function getEffectiveDraftCliSlots() {
|
||||
return resolveEffectiveClientCliStatusLineSlots({
|
||||
cliStatusLineSlots: draftCliStatusLineSlots,
|
||||
topbarCapsuleSlots: draftTopbarSlots,
|
||||
});
|
||||
}
|
||||
|
||||
function isStructureVisible() {
|
||||
const st = uiStore.getState();
|
||||
return getVisibleMonitorView(st) === 'settings' && st.settingsSubTab === 'structure';
|
||||
@@ -254,6 +351,50 @@ export const SettingsStructureTab = defineComponent({
|
||||
className: 'form-label',
|
||||
text: t('settings.str.cliCapsuleToggle'),
|
||||
});
|
||||
const cliSlotsLabelEl = h('span', {
|
||||
className: 'form-label',
|
||||
text: t('settings.str.cliSlotsLabel'),
|
||||
});
|
||||
const cliStatusHintEl = h('span', {
|
||||
className: 'settings-hint-text cli-status-hint',
|
||||
});
|
||||
let cliActionBusy = false;
|
||||
let activeCliStatusAction = '';
|
||||
const cliStatusActionBtn = h('button', {
|
||||
type: 'button',
|
||||
className: 'cli-status-action-btn',
|
||||
hidden: true,
|
||||
text: t('settings.str.cliRestoreBtn'),
|
||||
onClick: async () => {
|
||||
if (cliActionBusy || !activeCliStatusAction) return;
|
||||
cliActionBusy = true;
|
||||
const actionToRun = activeCliStatusAction;
|
||||
patchAttr(cliStatusActionBtn, 'disabled', true);
|
||||
patchText(cliStatusActionBtn, t('settings.str.cliRestoringBtn'));
|
||||
mountSection.refs.showStatus(t('settings.saving'), 0);
|
||||
try {
|
||||
const res = await triggerCliStatusLineAction(actionToRun);
|
||||
if (res?.cliStatusLine) {
|
||||
latestCliStatusLine = res.cliStatusLine;
|
||||
}
|
||||
if (res?.settings && typeof res.settings === 'object') {
|
||||
latestSettings = { ...(latestSettings || {}), ...res.settings };
|
||||
draftEnableCliStatusLine = latestSettings.enableCliStatusLine !== false;
|
||||
}
|
||||
mountSection.refs.showStatus(
|
||||
res?.ok === false ? t('settings.saveFailed') : t('settings.saved'),
|
||||
1800
|
||||
);
|
||||
} catch {
|
||||
mountSection.refs.showStatus(t('settings.saveFailed'), 2500);
|
||||
} finally {
|
||||
cliActionBusy = false;
|
||||
patchAttr(cliStatusActionBtn, 'disabled', false);
|
||||
syncMountSectionMeta();
|
||||
props.onLayoutChange?.();
|
||||
}
|
||||
},
|
||||
});
|
||||
const capsuleSlotsLabelEl = h('span', {
|
||||
className: 'form-label',
|
||||
text: t('settings.str.capsuleSlotsLabel'),
|
||||
@@ -334,12 +475,85 @@ export const SettingsStructureTab = defineComponent({
|
||||
onUpdateModelValue: (val) => {
|
||||
draftEnableCliStatusLine = val !== 'off';
|
||||
syncMountSectionMeta();
|
||||
props.onLayoutChange?.();
|
||||
void persistStructurePatch(mountSection, {
|
||||
enableCliStatusLine: draftEnableCliStatusLine,
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
const cliPreviewMultiTextEl = h('span', {
|
||||
text: t('settings.str.cliPreviewRunning', { count: 2 }),
|
||||
});
|
||||
const cliPreviewMultiEl = h('span', { className: 'cli-preview-multi' }, [
|
||||
h('span', { className: 'cli-preview-dot', 'aria-hidden': 'true', text: '●' }),
|
||||
cliPreviewMultiTextEl,
|
||||
]);
|
||||
const cliPreviewSlotParts = [];
|
||||
const cliPreviewSepEls = [];
|
||||
const cliPreviewChildren = [cliPreviewMultiEl];
|
||||
for (let i = 0; i < 6; i += 1) {
|
||||
if (i > 0) {
|
||||
const sepEl = h('span', {
|
||||
className: 'cli-preview-sep',
|
||||
'aria-hidden': 'true',
|
||||
text: '|',
|
||||
});
|
||||
cliPreviewSepEls.push(sepEl);
|
||||
cliPreviewChildren.push(sepEl);
|
||||
}
|
||||
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 slotEl = h('span', { className: 'cli-preview-slot' }, [
|
||||
prefixEl,
|
||||
barFillEl,
|
||||
barEmptyEl,
|
||||
valueEl,
|
||||
]);
|
||||
cliPreviewSlotParts.push({ slotEl, prefixEl, barFillEl, barEmptyEl, valueEl });
|
||||
cliPreviewChildren.push(slotEl);
|
||||
}
|
||||
const cliPreviewEl = h('div', { className: 'cli-status-preview' }, cliPreviewChildren);
|
||||
|
||||
const cliSlotsList = EditableSlotList({
|
||||
items: getEffectiveDraftCliSlots(),
|
||||
options: getCapsuleMetricOptions(),
|
||||
minItems: 1,
|
||||
maxItems: 6,
|
||||
addBtnTextFn: (count, max) => t('settings.str.addCliSlot', { count, max }),
|
||||
onPreview: (previewItems) => {
|
||||
draftCliStatusLineSlots = normalizeClientCliStatusLineSlots(previewItems);
|
||||
refreshCliPreview();
|
||||
},
|
||||
onChange: (nextItems) => {
|
||||
draftCliStatusLineSlots = normalizeClientCliStatusLineSlots(nextItems);
|
||||
syncMountSectionMeta();
|
||||
props.onLayoutChange?.();
|
||||
void persistStructurePatch(mountSection, {
|
||||
cliStatusLineSlots: draftCliStatusLineSlots,
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
const cliStatusFooterEl = h('div', { className: 'cli-status-footer', hidden: true }, [
|
||||
cliStatusHintEl,
|
||||
cliStatusActionBtn,
|
||||
]);
|
||||
|
||||
const cliStatusDetailEl = h('div', { className: 'cli-statusline-detail' }, [
|
||||
cliPreviewEl,
|
||||
h('div', { className: 'form-row' }, [cliSlotsLabelEl, cliSlotsList.el]),
|
||||
cliStatusFooterEl,
|
||||
]);
|
||||
|
||||
const cliStatusGroupEl = h('div', { className: 'cli-statusline-group', hidden: true }, [
|
||||
h('div', { className: 'settings-divider' }),
|
||||
h('div', { className: 'settings-inline-row' }, [cliCapsuleLabelEl, cliCapsuleToggle.el]),
|
||||
cliStatusDetailEl,
|
||||
]);
|
||||
|
||||
const topbarSlotsList = EditableSlotList({
|
||||
items: draftTopbarSlots,
|
||||
options: getCapsuleMetricOptions(),
|
||||
@@ -373,6 +587,7 @@ export const SettingsStructureTab = defineComponent({
|
||||
draftPopoverWidth = DEFAULT_CLIENT_POPOVER_WIDTH;
|
||||
popoverWidthStepper.setProps({ modelValue: DEFAULT_CLIENT_POPOVER_WIDTH });
|
||||
draftEnableCliStatusLine = true;
|
||||
draftCliStatusLineSlots = null;
|
||||
draftShowTopbarMulti = true;
|
||||
draftTopbarSlots = [...DEFAULT_CLIENT_TOPBAR_SLOTS];
|
||||
syncMountSectionMeta();
|
||||
@@ -385,6 +600,7 @@ export const SettingsStructureTab = defineComponent({
|
||||
popoverWidthMode: 'auto',
|
||||
popoverWidth: DEFAULT_CLIENT_POPOVER_WIDTH,
|
||||
enableCliStatusLine: true,
|
||||
cliStatusLineSlots: null,
|
||||
showTopbarMultiSession: true,
|
||||
topbarCapsuleSlots: [...DEFAULT_CLIENT_TOPBAR_SLOTS],
|
||||
},
|
||||
@@ -410,17 +626,44 @@ export const SettingsStructureTab = defineComponent({
|
||||
multiToggleLabelEl,
|
||||
multiSessionToggle.el,
|
||||
]),
|
||||
h('div', { className: 'settings-inline-row' }, [
|
||||
cliCapsuleLabelEl,
|
||||
cliCapsuleToggle.el,
|
||||
]),
|
||||
h('div', { className: 'form-row' }, [capsuleSlotsLabelEl, topbarSlotsList.el]),
|
||||
cliStatusGroupEl,
|
||||
],
|
||||
});
|
||||
|
||||
function refreshCliPreview() {
|
||||
const effectiveSlots = getEffectiveDraftCliSlots();
|
||||
const isEn = getEffectiveLocale() === 'en-US';
|
||||
patchAttr(cliPreviewMultiEl, 'hidden', !draftShowTopbarMulti);
|
||||
patchText(cliPreviewMultiTextEl, t('settings.str.cliPreviewRunning', { count: 2 }));
|
||||
for (let i = 0; i < cliPreviewSlotParts.length; i += 1) {
|
||||
const parts = cliPreviewSlotParts[i];
|
||||
const sepEl = i > 0 ? cliPreviewSepEls[i - 1] : null;
|
||||
const key = effectiveSlots[i];
|
||||
const visible = Boolean(key);
|
||||
patchAttr(parts.slotEl, 'hidden', !visible);
|
||||
if (sepEl) patchAttr(sepEl, 'hidden', !visible);
|
||||
if (visible) {
|
||||
const item = formatCliPreviewSlot(key, isEn);
|
||||
patchAttr(parts.slotEl, 'data-metric', key);
|
||||
patchText(parts.prefixEl, item.prefix || '');
|
||||
patchText(parts.barFillEl, item.barFilled || '');
|
||||
patchText(parts.barEmptyEl, item.barEmpty || '');
|
||||
patchText(parts.valueEl, item.text || '');
|
||||
patchClasses(parts.slotEl, {
|
||||
'tone-good': item.tone === 'good',
|
||||
'tone-info': item.tone === 'info',
|
||||
'tone-accent': item.tone === 'accent',
|
||||
'tone-muted': item.tone === 'muted',
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function refreshMountPreview() {
|
||||
if (!isStructureVisible() || activeThirdTab !== 'mount') return;
|
||||
capsulePreviewWidget.refs.update({ data: buildDraftTelemetry() });
|
||||
refreshCliPreview();
|
||||
}
|
||||
|
||||
function syncMountSectionMeta() {
|
||||
@@ -448,10 +691,53 @@ export const SettingsStructureTab = defineComponent({
|
||||
modelValue: draftShowTopbarMulti ? 'show' : 'hide',
|
||||
options: getMultiToggleOptions(),
|
||||
});
|
||||
const cliInstalled = Boolean(latestCliStatusLine?.installed);
|
||||
patchAttr(cliStatusGroupEl, 'hidden', !cliInstalled);
|
||||
cliCapsuleToggle.setProps({
|
||||
modelValue: draftEnableCliStatusLine ? 'on' : 'off',
|
||||
options: getEnableToggleOptions(),
|
||||
});
|
||||
patchAttr(cliStatusDetailEl, 'hidden', !draftEnableCliStatusLine);
|
||||
const effectiveCliSlots = getEffectiveDraftCliSlots();
|
||||
cliSlotsList.refs.setProps({
|
||||
items: effectiveCliSlots,
|
||||
options: getCapsuleMetricOptions(),
|
||||
addBtnTextFn: (count, max) => t('settings.str.addCliSlot', { count, max }),
|
||||
});
|
||||
const preservedCustom = Boolean(latestCliStatusLine?.preservedCustom);
|
||||
const isConfigured = Boolean(latestCliStatusLine?.configured);
|
||||
const hasInlineSlotFlags = /(?:^|\s)--(?:slots|preset)(?:=|\s|$)/i.test(
|
||||
String(latestCliStatusLine?.managedFlags || '')
|
||||
);
|
||||
const isPausedInCli = cliInstalled && !preservedCustom && !isConfigured && draftEnableCliStatusLine;
|
||||
const cliHintText = preservedCustom
|
||||
? t('settings.str.cliCustomCmdHint')
|
||||
: isPausedInCli
|
||||
? t('settings.str.cliPausedHint')
|
||||
: hasInlineSlotFlags
|
||||
? t('settings.str.cliFlagsOverrideHint')
|
||||
: '';
|
||||
patchAttr(cliStatusFooterEl, 'hidden', !cliHintText);
|
||||
patchClasses(cliStatusHintEl, { 'is-warn': preservedCustom || isPausedInCli });
|
||||
patchText(cliStatusHintEl, cliHintText);
|
||||
activeCliStatusAction = preservedCustom || isPausedInCli
|
||||
? 'force_install'
|
||||
: hasInlineSlotFlags
|
||||
? 'clear_flags'
|
||||
: '';
|
||||
patchAttr(cliStatusActionBtn, 'hidden', !activeCliStatusAction);
|
||||
patchClasses(cliStatusActionBtn, { 'is-warn': preservedCustom });
|
||||
if (!cliActionBusy && activeCliStatusAction) {
|
||||
patchText(
|
||||
cliStatusActionBtn,
|
||||
preservedCustom
|
||||
? t('settings.str.cliRestoreBtn')
|
||||
: isPausedInCli
|
||||
? t('settings.str.cliEnableBtn')
|
||||
: t('settings.str.cliClearFlagsBtn')
|
||||
);
|
||||
}
|
||||
refreshCliPreview();
|
||||
topbarSlotsList.refs.setProps({
|
||||
items: draftTopbarSlots,
|
||||
options: getCapsuleMetricOptions(),
|
||||
@@ -465,6 +751,7 @@ export const SettingsStructureTab = defineComponent({
|
||||
draftPopoverWidthMode === 'auto' &&
|
||||
draftPopoverWidth === DEFAULT_CLIENT_POPOVER_WIDTH &&
|
||||
draftEnableCliStatusLine === true &&
|
||||
draftCliStatusLineSlots === null &&
|
||||
draftShowTopbarMulti === true &&
|
||||
isSameList(draftTopbarSlots, DEFAULT_CLIENT_TOPBAR_SLOTS);
|
||||
mountSection.refs.setResetDisabled(isDefault);
|
||||
@@ -1030,12 +1317,14 @@ export const SettingsStructureTab = defineComponent({
|
||||
function renderSettings(
|
||||
settings,
|
||||
windowBridge = latestWindowBridge,
|
||||
hostPlatform = latestHostPlatform
|
||||
hostPlatform = latestHostPlatform,
|
||||
cliStatusLine = latestCliStatusLine
|
||||
) {
|
||||
if (!settings) return;
|
||||
latestSettings = settings;
|
||||
if (windowBridge !== undefined) latestWindowBridge = windowBridge;
|
||||
if (hostPlatform) latestHostPlatform = hostPlatform;
|
||||
if (cliStatusLine !== undefined) latestCliStatusLine = cliStatusLine;
|
||||
draftWindowMountMode = normalizeClientWindowMountMode(
|
||||
settings.windowMountMode,
|
||||
settings.enableWindowOverlay
|
||||
@@ -1043,6 +1332,7 @@ export const SettingsStructureTab = defineComponent({
|
||||
draftPopoverWidthMode = normalizeClientPopoverWidthMode(settings.popoverWidthMode);
|
||||
draftPopoverWidth = normalizeClientPopoverWidth(settings.popoverWidth);
|
||||
draftEnableCliStatusLine = settings.enableCliStatusLine !== false;
|
||||
draftCliStatusLineSlots = normalizeClientCliStatusLineSlots(settings.cliStatusLineSlots);
|
||||
draftShowTopbarMulti = settings.showTopbarMultiSession !== false;
|
||||
draftTopbarSlots = normalizeClientTopbarSlots(settings.topbarCapsuleSlots);
|
||||
draftHoverModules = normalizeClientHoverModules(settings.hoverModules);
|
||||
@@ -1077,6 +1367,7 @@ export const SettingsStructureTab = defineComponent({
|
||||
popoverWidthStepper.setProps({ ariaLabel: t('settings.str.popoverWidthLabel') });
|
||||
patchText(multiToggleLabelEl, t('settings.str.multiToggle'));
|
||||
patchText(cliCapsuleLabelEl, t('settings.str.cliCapsuleToggle'));
|
||||
patchText(cliSlotsLabelEl, t('settings.str.cliSlotsLabel'));
|
||||
patchText(capsuleSlotsLabelEl, t('settings.str.capsuleSlotsLabel'));
|
||||
|
||||
hoverSection.refs.setTitle(t('settings.str.hoverSection'));
|
||||
@@ -1147,6 +1438,7 @@ export const SettingsStructureTab = defineComponent({
|
||||
popoverWidthModeToggle.destroy();
|
||||
multiSessionToggle.destroy();
|
||||
cliCapsuleToggle.destroy();
|
||||
cliSlotsList.destroy();
|
||||
topbarSlotsList.destroy();
|
||||
hoverModulesList.destroy();
|
||||
overviewModulesList.destroy();
|
||||
@@ -1173,6 +1465,13 @@ export const SettingsStructureTab = defineComponent({
|
||||
windowMountSelect,
|
||||
multiSessionToggle,
|
||||
cliCapsuleToggle,
|
||||
cliStatusGroupEl,
|
||||
cliStatusDetailEl,
|
||||
cliPreviewEl,
|
||||
cliSlotsList,
|
||||
cliStatusFooterEl,
|
||||
cliStatusHintEl,
|
||||
cliStatusActionBtn,
|
||||
topbarSlotsList,
|
||||
hoverModulesList,
|
||||
overviewModulesList,
|
||||
|
||||
Reference in New Issue
Block a user