mirror of
https://github.com/lWolvesl/antigravity-usage-monitor.git
synced 2026-11-27 01:19:25 +08:00
feat(panel): add local CloudCode proxy sync and independent Main/Subagent-Swarm context window toggles (#36)
This commit is contained in:
@@ -704,6 +704,9 @@ export const I18N_MESSAGES_EN_US = Object.freeze({
|
||||
'settings.oth.ctxRiskBody': 'Google has not authorized modifying model context limits in Antigravity App / IDE. Altering context limits may get your Antigravity access, GCP services, or Google account disabled or banned; enabling this feature means you assume all associated risks. Make sure you know what you are doing!',
|
||||
'settings.oth.ctxRiskAcceptBtn': 'I Understand the Risk, Unlock',
|
||||
'settings.oth.ctxModel': 'Model',
|
||||
'settings.oth.ctxMainLabel': 'Main Agent',
|
||||
'settings.oth.ctxSwarmLabel': 'Subagents & Swarm',
|
||||
'settings.oth.ctxSwarmError': 'Local sync failed: {error}',
|
||||
'settings.oth.ctxBaselineLabel': 'Context Window Limit',
|
||||
'settings.oth.ctxChooseModel': 'Choose a model',
|
||||
'settings.oth.ctxDefault': 'Follow host settings',
|
||||
|
||||
@@ -704,6 +704,9 @@ export const I18N_MESSAGES_ZH_CN = Object.freeze({
|
||||
'settings.oth.ctxRiskBody': 'Google 官方并未授权在 Antigravity App / IDE 中修改模型上下文上限。擅自修改可能导致 Antigravity 或 GCP 服务被禁用,甚至触发账号封禁;启用该功能即默认由你自行承担全部风险。你最好清楚自己在做什么!',
|
||||
'settings.oth.ctxRiskAcceptBtn': '我已知晓风险,继续使用',
|
||||
'settings.oth.ctxModel': '模型',
|
||||
'settings.oth.ctxMainLabel': '主代理',
|
||||
'settings.oth.ctxSwarmLabel': '子代理与蜂群',
|
||||
'settings.oth.ctxSwarmError': '本地同步异常:{error}',
|
||||
'settings.oth.ctxBaselineLabel': '上下文窗口上限',
|
||||
'settings.oth.ctxChooseModel': '选择模型',
|
||||
'settings.oth.ctxDefault': '跟随宿主设置',
|
||||
|
||||
@@ -540,6 +540,20 @@ export function isEquivalentTelemetry(prev, next) {
|
||||
if (Boolean(pSet?.contextWindowRiskAccepted) !== Boolean(nSet?.contextWindowRiskAccepted)) {
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
(pSet?.contextWindowMainEnabled !== false) !== (nSet?.contextWindowMainEnabled !== false) ||
|
||||
Boolean(pSet?.contextWindowSwarmEnabled) !== Boolean(nSet?.contextWindowSwarmEnabled)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
(prev.cloudCodeProxy?.state || 'disabled') !== (next.cloudCodeProxy?.state || 'disabled') ||
|
||||
Number(prev.cloudCodeProxy?.ruleCount || 0) !== Number(next.cloudCodeProxy?.ruleCount || 0) ||
|
||||
String(prev.cloudCodeProxy?.error || '') !== String(next.cloudCodeProxy?.error || '') ||
|
||||
Number(prev.cloudCodeProxy?.syncedAtMs || 0) !== Number(next.cloudCodeProxy?.syncedAtMs || 0)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
JSON.stringify(pSet?.modelContextWindows) !== JSON.stringify(nSet?.modelContextWindows) ||
|
||||
JSON.stringify(prev.contextWindowModels) !== JSON.stringify(next.contextWindowModels)
|
||||
@@ -1856,6 +1870,12 @@ export async function saveSettingsPatch(patch) {
|
||||
if (Object.prototype.hasOwnProperty.call(safePatch, 'contextWindowRiskAccepted')) {
|
||||
safePatch.contextWindowRiskAccepted = Boolean(safePatch.contextWindowRiskAccepted);
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(safePatch, 'contextWindowMainEnabled')) {
|
||||
safePatch.contextWindowMainEnabled = Boolean(safePatch.contextWindowMainEnabled);
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(safePatch, 'contextWindowSwarmEnabled')) {
|
||||
safePatch.contextWindowSwarmEnabled = Boolean(safePatch.contextWindowSwarmEnabled);
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(safePatch, 'orchestratorIdMode')) {
|
||||
safePatch.orchestratorIdMode = normalizeClientOrchestratorIdMode(safePatch.orchestratorIdMode);
|
||||
}
|
||||
|
||||
@@ -793,6 +793,14 @@
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.ctx-sync-status {
|
||||
margin: -4px 0 2px;
|
||||
}
|
||||
|
||||
.ctx-sync-status.is-error {
|
||||
color: var(--metric-warn);
|
||||
}
|
||||
|
||||
.ctx-risk-mask {
|
||||
grid-area: 1 / 1;
|
||||
z-index: 5;
|
||||
|
||||
@@ -118,7 +118,8 @@ export const SettingsView = defineComponent({
|
||||
settings,
|
||||
telemetry.contextWindowModels || [],
|
||||
telemetry?.windowBridge,
|
||||
telemetry?.hostPlatform
|
||||
telemetry?.hostPlatform,
|
||||
telemetry?.cloudCodeProxy
|
||||
);
|
||||
}
|
||||
} else if (accountTab && settingsSubTab === 'account') {
|
||||
@@ -134,6 +135,7 @@ export const SettingsView = defineComponent({
|
||||
(st) => ({
|
||||
settings: st.telemetry?.settings,
|
||||
windowBridge: st.telemetry?.windowBridge,
|
||||
cloudCodeProxy: st.telemetry?.cloudCodeProxy,
|
||||
cliStatusLine: st.telemetry?.cliStatusLine,
|
||||
hostPlatform: st.telemetry?.hostPlatform,
|
||||
cloudStatus: st.telemetry?.cloudStatus,
|
||||
|
||||
@@ -77,8 +77,12 @@ export const SettingsOtherTab = defineComponent({
|
||||
let draftExperimentalQuotaReservation = false;
|
||||
let draftContextRiskAccepted = false;
|
||||
let acceptingContextRisk = false;
|
||||
let draftContextMainEnabled = true;
|
||||
let draftContextSwarmEnabled = false;
|
||||
let savingContextScope = false;
|
||||
let latestSettings = null;
|
||||
let latestWindowBridge = null;
|
||||
let latestCloudCodeProxy = null;
|
||||
let latestHostPlatform = 'win32';
|
||||
let contextWindowModels = [];
|
||||
let contextModelId = '';
|
||||
@@ -358,10 +362,79 @@ export const SettingsOtherTab = defineComponent({
|
||||
},
|
||||
});
|
||||
const ctxBridgeNotice = BridgeStatusNotice({ contextMode: true });
|
||||
const ctxMainLabelEl = h('span', {
|
||||
className: 'form-label',
|
||||
text: t('settings.oth.ctxMainLabel'),
|
||||
});
|
||||
const ctxMainToggle = SegmentedControl({
|
||||
modelValue: 'on',
|
||||
ariaLabel: t('settings.oth.ctxMainLabel'),
|
||||
options: getEnableToggleOptions(),
|
||||
onUpdateModelValue: async (val) => {
|
||||
if (!draftContextRiskAccepted || savingContextScope) return;
|
||||
const nextEnabled = val === 'on';
|
||||
const prevEnabled = draftContextMainEnabled;
|
||||
savingContextScope = true;
|
||||
draftContextMainEnabled = nextEnabled;
|
||||
latestSettings = { ...(latestSettings || {}), contextWindowMainEnabled: nextEnabled };
|
||||
contextFeedback = 'settings.saving';
|
||||
renderContextWindows();
|
||||
try {
|
||||
await saveSettingsPatch({ contextWindowMainEnabled: nextEnabled });
|
||||
contextFeedback = 'settings.saved';
|
||||
} catch {
|
||||
draftContextMainEnabled = prevEnabled;
|
||||
latestSettings = { ...(latestSettings || {}), contextWindowMainEnabled: prevEnabled };
|
||||
contextFeedback = 'settings.saveFailed';
|
||||
} finally {
|
||||
savingContextScope = false;
|
||||
renderContextWindows();
|
||||
}
|
||||
},
|
||||
});
|
||||
const ctxSwarmLabelEl = h('span', {
|
||||
className: 'form-label',
|
||||
text: t('settings.oth.ctxSwarmLabel'),
|
||||
});
|
||||
const ctxSwarmToggle = SegmentedControl({
|
||||
modelValue: 'off',
|
||||
ariaLabel: t('settings.oth.ctxSwarmLabel'),
|
||||
options: getEnableToggleOptions(),
|
||||
onUpdateModelValue: async (val) => {
|
||||
if (!draftContextRiskAccepted || savingContextScope) return;
|
||||
const nextEnabled = val === 'on';
|
||||
const prevEnabled = draftContextSwarmEnabled;
|
||||
savingContextScope = true;
|
||||
draftContextSwarmEnabled = nextEnabled;
|
||||
latestSettings = { ...(latestSettings || {}), contextWindowSwarmEnabled: nextEnabled };
|
||||
contextFeedback = 'settings.saving';
|
||||
renderContextWindows();
|
||||
try {
|
||||
await saveSettingsPatch({ contextWindowSwarmEnabled: nextEnabled });
|
||||
contextFeedback = 'settings.saved';
|
||||
} catch {
|
||||
draftContextSwarmEnabled = prevEnabled;
|
||||
latestSettings = { ...(latestSettings || {}), contextWindowSwarmEnabled: prevEnabled };
|
||||
contextFeedback = 'settings.saveFailed';
|
||||
} finally {
|
||||
savingContextScope = false;
|
||||
renderContextWindows();
|
||||
}
|
||||
},
|
||||
});
|
||||
const ctxMainRow = h('div', { className: 'form-row' }, [ctxMainLabelEl, ctxMainToggle.el]);
|
||||
const ctxSwarmRow = h('div', { className: 'form-row' }, [ctxSwarmLabelEl, ctxSwarmToggle.el]);
|
||||
const ctxSyncStatusEl = h('span', {
|
||||
className: 'settings-hint-text ctx-sync-status is-error',
|
||||
hidden: true,
|
||||
});
|
||||
const ctxModelRow = h('div', { className: 'form-row' }, [ctxModelLabel, ctxModelSelect.el]);
|
||||
const ctxWindowRow = h('div', { className: 'form-row' }, [ctxWindowLabel, ctxWindowSelect.el]);
|
||||
const ctxControlsBody = h('div', { className: 'ctx-controls-body is-locked' }, [
|
||||
ctxBridgeNotice.el,
|
||||
ctxMainRow,
|
||||
ctxSwarmRow,
|
||||
ctxSyncStatusEl,
|
||||
ctxModelRow,
|
||||
ctxWindowRow,
|
||||
h('div', { className: 'form-row' }, [ctxHint]),
|
||||
@@ -440,8 +513,31 @@ export const SettingsOtherTab = defineComponent({
|
||||
const saved = latestSettings?.modelContextWindows || {};
|
||||
const wbState = String(latestWindowBridge?.state || '').trim();
|
||||
const isBridgeMissing = wbState === 'no_devtools_port' || wbState === 'cdp_unreachable';
|
||||
const proxyState = String(latestCloudCodeProxy?.state || 'disabled');
|
||||
const isProxyActive = Boolean(latestCloudCodeProxy?.active && proxyState === 'active');
|
||||
|
||||
patchText(ctxMainLabelEl, t('settings.oth.ctxMainLabel'));
|
||||
ctxMainToggle.setProps({
|
||||
modelValue: draftContextMainEnabled ? 'on' : 'off',
|
||||
options: getEnableToggleOptions(),
|
||||
ariaLabel: t('settings.oth.ctxMainLabel'),
|
||||
});
|
||||
patchText(ctxSwarmLabelEl, t('settings.oth.ctxSwarmLabel'));
|
||||
ctxSwarmToggle.setProps({
|
||||
modelValue: draftContextSwarmEnabled ? 'on' : 'off',
|
||||
options: getEnableToggleOptions(),
|
||||
ariaLabel: t('settings.oth.ctxSwarmLabel'),
|
||||
});
|
||||
|
||||
const syncErrorText =
|
||||
draftContextSwarmEnabled && proxyState === 'error' && latestCloudCodeProxy?.error
|
||||
? t('settings.oth.ctxSwarmError', { error: latestCloudCodeProxy.error })
|
||||
: '';
|
||||
patchAttr(ctxSyncStatusEl, 'hidden', !syncErrorText);
|
||||
patchText(ctxSyncStatusEl, syncErrorText);
|
||||
|
||||
ctxBridgeNotice.refs.update({
|
||||
visible: unlocked,
|
||||
visible: unlocked && draftContextMainEnabled,
|
||||
windowBridge: latestWindowBridge,
|
||||
hostPlatform: latestHostPlatform,
|
||||
});
|
||||
@@ -489,7 +585,13 @@ export const SettingsOtherTab = defineComponent({
|
||||
else if (value) {
|
||||
const name = formatLimit(value);
|
||||
if (!isAvailable(model, value)) meta = t('settings.oth.ctxUnavailable', { name });
|
||||
else if (isBridgeMissing) meta = t('settings.oth.ctxPendingBridge', { name });
|
||||
else if (
|
||||
isBridgeMissing &&
|
||||
draftContextMainEnabled &&
|
||||
!(draftContextSwarmEnabled && isProxyActive)
|
||||
) {
|
||||
meta = t('settings.oth.ctxPendingBridge', { name });
|
||||
}
|
||||
else if (/^\d+$/.test(value) && model.reportedLimitTokens && Number(value) !== model.reportedLimitTokens) {
|
||||
meta = t('settings.oth.ctxConfiguredReported', {
|
||||
name,
|
||||
@@ -777,13 +879,15 @@ export const SettingsOtherTab = defineComponent({
|
||||
settings,
|
||||
models = contextWindowModels,
|
||||
windowBridge = latestWindowBridge,
|
||||
hostPlatform = latestHostPlatform
|
||||
hostPlatform = latestHostPlatform,
|
||||
cloudCodeProxy = latestCloudCodeProxy
|
||||
) {
|
||||
if (!settings) return;
|
||||
latestSettings = settings;
|
||||
contextWindowModels = models;
|
||||
if (windowBridge !== undefined) latestWindowBridge = windowBridge;
|
||||
if (hostPlatform) latestHostPlatform = hostPlatform;
|
||||
if (cloudCodeProxy !== undefined) latestCloudCodeProxy = cloudCodeProxy;
|
||||
draftModelDisplayMode = normalizeClientModelDisplayMode(
|
||||
settings.modelDisplayMode,
|
||||
settings.showUpstreamModel
|
||||
@@ -795,6 +899,10 @@ export const SettingsOtherTab = defineComponent({
|
||||
if (!acceptingContextRisk) {
|
||||
draftContextRiskAccepted = Boolean(settings.contextWindowRiskAccepted);
|
||||
}
|
||||
if (!savingContextScope) {
|
||||
draftContextMainEnabled = settings.contextWindowMainEnabled !== false;
|
||||
draftContextSwarmEnabled = settings.contextWindowSwarmEnabled === true;
|
||||
}
|
||||
stepModelSelect.setProps({
|
||||
modelValue: draftModelDisplayMode,
|
||||
options: getStepModelDisplayOptions(),
|
||||
@@ -870,6 +978,8 @@ export const SettingsOtherTab = defineComponent({
|
||||
orchestratorIdSelect.destroy();
|
||||
quotaReserveToggle.destroy();
|
||||
ctxBridgeNotice.destroy();
|
||||
ctxMainToggle.destroy();
|
||||
ctxSwarmToggle.destroy();
|
||||
ctxModelSelect.destroy();
|
||||
ctxWindowSelect.destroy();
|
||||
sessionMigrationCard.destroy();
|
||||
@@ -883,6 +993,8 @@ export const SettingsOtherTab = defineComponent({
|
||||
quotaReserveToggle,
|
||||
exportReserveLogBtn,
|
||||
ctxBridgeNotice,
|
||||
ctxMainToggle,
|
||||
ctxSwarmToggle,
|
||||
ctxModelSelect,
|
||||
ctxWindowSelect,
|
||||
sessionMigrationCard,
|
||||
|
||||
Reference in New Issue
Block a user