mirror of
https://github.com/lWolvesl/antigravity-usage-monitor.git
synced 2026-11-26 17:09:28 +08:00
feat(panel): default-lock topbar capsule and hover context to main agent with toggle (#35)
This commit is contained in:
@@ -11,6 +11,7 @@ import { createSvgIcon } from './icons/SvgIcon.js';
|
||||
import { i18nStore, t } from './i18n/index.js';
|
||||
import {
|
||||
fetchTelemetry,
|
||||
getDefaultCtxInspectorAgentId,
|
||||
normalizeClientWindowMountMode,
|
||||
resolveScopedConversation,
|
||||
telemetryStore,
|
||||
@@ -293,6 +294,24 @@ export const App = defineComponent({
|
||||
}
|
||||
);
|
||||
|
||||
let syncedSettingsCtxMode = null;
|
||||
|
||||
function syncContextAgentModeFromSettings(settings) {
|
||||
if (!settings || typeof settings !== 'object') return;
|
||||
const nextMode = getDefaultCtxInspectorAgentId(settings);
|
||||
if (nextMode === syncedSettingsCtxMode) return;
|
||||
const prevSynced = syncedSettingsCtxMode;
|
||||
syncedSettingsCtxMode = nextMode;
|
||||
const curCtx = uiStore.getState().ctxInspectorAgentId;
|
||||
if (prevSynced !== null || curCtx === 'main' || curCtx === 'auto') {
|
||||
if (curCtx !== nextMode) {
|
||||
uiStore.setState({ ctxInspectorAgentId: nextMode });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
syncContextAgentModeFromSettings(telemetryStore.getState().telemetry?.settings);
|
||||
|
||||
const unsubStepCount = telemetryStore.subscribe(
|
||||
(st) => ({
|
||||
stepCount: st.telemetry?.activeConversation?.stepCount ?? 0,
|
||||
@@ -300,11 +319,13 @@ export const App = defineComponent({
|
||||
subagentCount: st.telemetry?.activeConversation?.subagentCount ?? 0,
|
||||
windowMountMode: st.telemetry?.settings?.windowMountMode,
|
||||
enableWindowOverlay: st.telemetry?.settings?.enableWindowOverlay,
|
||||
contextAgentMode: st.telemetry?.settings?.contextAgentMode,
|
||||
modelContextWindows: st.telemetry?.settings?.modelContextWindows,
|
||||
windowBridge: st.telemetry?.windowBridge,
|
||||
hostPlatform: st.telemetry?.hostPlatform,
|
||||
}),
|
||||
() => {
|
||||
syncContextAgentModeFromSettings(telemetryStore.getState().telemetry?.settings);
|
||||
syncStepsBadge();
|
||||
syncGlobalBridgeBanner();
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
fetchTelemetry,
|
||||
formatAgentBadgeText,
|
||||
formatConversationMeta,
|
||||
getDefaultCtxInspectorAgentId,
|
||||
normalizeClientUpdateMode,
|
||||
resolveHostRouteMatch,
|
||||
selectConversation,
|
||||
@@ -125,6 +126,7 @@ export const TopSessionHeader = defineComponent({
|
||||
|
||||
let lastActiveCascadeId = '';
|
||||
let lastAppliedHostChildRouteId = '';
|
||||
let preChildCtxInspectorAgentId = '';
|
||||
|
||||
function syncSessionScopeOnCascadeChange(telemetry, telSlice = telemetryStore.getState()) {
|
||||
const currentCascadeId = telemetry?.activeConversation?.cascadeId || '';
|
||||
@@ -133,15 +135,22 @@ export const TopSessionHeader = defineComponent({
|
||||
const selectedId = String(telSlice?.selectedConversationId || '').trim();
|
||||
const hostRouteId = String(telSlice?.hostRouteConversationId || '').trim();
|
||||
const hostRouteLower = hostRouteId.toLowerCase();
|
||||
const defaultCtxId = getDefaultCtxInspectorAgentId(telemetry?.settings);
|
||||
|
||||
if (!selectedId && hostRouteLower) {
|
||||
const routeMatch = resolveHostRouteMatch(telemetry, hostRouteId);
|
||||
if (routeMatch?.isChildRoute && routeMatch.childAgent?.agentId) {
|
||||
lastActiveCascadeId = currentCascadeId;
|
||||
if (lastAppliedHostChildRouteId !== hostRouteLower) {
|
||||
const uiSt = uiStore.getState();
|
||||
if (!lastAppliedHostChildRouteId) {
|
||||
preChildCtxInspectorAgentId =
|
||||
uiSt.ctxInspectorAgentId === 'main' || uiSt.ctxInspectorAgentId === 'auto'
|
||||
? uiSt.ctxInspectorAgentId
|
||||
: defaultCtxId;
|
||||
}
|
||||
lastAppliedHostChildRouteId = hostRouteLower;
|
||||
const targetAgentId = routeMatch.childAgent.agentId;
|
||||
const uiSt = uiStore.getState();
|
||||
if (
|
||||
uiSt.selectedAgentScope !== targetAgentId ||
|
||||
uiSt.ctxInspectorAgentId !== targetAgentId
|
||||
@@ -155,23 +164,30 @@ export const TopSessionHeader = defineComponent({
|
||||
return;
|
||||
}
|
||||
if (lastAppliedHostChildRouteId && !routeMatch?.isChildRoute) {
|
||||
const restoreCtxId =
|
||||
preChildCtxInspectorAgentId === 'main' || preChildCtxInspectorAgentId === 'auto'
|
||||
? preChildCtxInspectorAgentId
|
||||
: defaultCtxId;
|
||||
lastAppliedHostChildRouteId = '';
|
||||
preChildCtxInspectorAgentId = '';
|
||||
const uiSt = uiStore.getState();
|
||||
if (uiSt.selectedAgentScope !== 'all' || uiSt.ctxInspectorAgentId !== 'auto') {
|
||||
uiStore.setState({ selectedAgentScope: 'all', ctxInspectorAgentId: 'auto' });
|
||||
if (uiSt.selectedAgentScope !== 'all' || uiSt.ctxInspectorAgentId !== restoreCtxId) {
|
||||
uiStore.setState({ selectedAgentScope: 'all', ctxInspectorAgentId: restoreCtxId });
|
||||
}
|
||||
lastActiveCascadeId = currentCascadeId;
|
||||
return;
|
||||
}
|
||||
} else if (lastAppliedHostChildRouteId) {
|
||||
lastAppliedHostChildRouteId = '';
|
||||
preChildCtxInspectorAgentId = '';
|
||||
}
|
||||
|
||||
if (lastActiveCascadeId && currentCascadeId !== lastActiveCascadeId) {
|
||||
lastActiveCascadeId = currentCascadeId;
|
||||
preChildCtxInspectorAgentId = '';
|
||||
const uiSt = uiStore.getState();
|
||||
if (uiSt.selectedAgentScope !== 'all' || uiSt.ctxInspectorAgentId !== 'auto') {
|
||||
uiStore.setState({ selectedAgentScope: 'all', ctxInspectorAgentId: 'auto' });
|
||||
if (uiSt.selectedAgentScope !== 'all' || uiSt.ctxInspectorAgentId !== defaultCtxId) {
|
||||
uiStore.setState({ selectedAgentScope: 'all', ctxInspectorAgentId: defaultCtxId });
|
||||
}
|
||||
} else {
|
||||
lastActiveCascadeId = currentCascadeId;
|
||||
|
||||
@@ -46,6 +46,7 @@ import {
|
||||
DEFAULT_CLIENT_HOVER_MODULES,
|
||||
extractHostRouteCascadeId,
|
||||
fetchTelemetry,
|
||||
getDefaultCtxInspectorAgentId,
|
||||
isMacHostPlatform,
|
||||
normalizeClientHoverModules,
|
||||
normalizeClientPopoverWidth,
|
||||
@@ -54,6 +55,8 @@ import {
|
||||
normalizeClientUpdateMode,
|
||||
normalizeClientWindowMountMode,
|
||||
resetTelemetryForEndpointSwitch,
|
||||
resolveHostRouteMatch,
|
||||
resolveOverlayCtxInspectorAgentId,
|
||||
resolveScopedConversation,
|
||||
selectConversation,
|
||||
startAsyncTelemetryLoop,
|
||||
@@ -1096,7 +1099,9 @@ export function mountWindowOverlay() {
|
||||
uiStore.setState({
|
||||
activeView: 'overview',
|
||||
selectedAgentScope: 'all',
|
||||
ctxInspectorAgentId: 'auto',
|
||||
ctxInspectorAgentId: getDefaultCtxInspectorAgentId(
|
||||
telemetryStore.getState().telemetry?.settings
|
||||
),
|
||||
});
|
||||
void selectConversation(cascadeId);
|
||||
setMultiOpen(false);
|
||||
@@ -1375,6 +1380,11 @@ export function mountWindowOverlay() {
|
||||
mode: 'hover',
|
||||
isVisibleFn: () => Boolean(tooltipOpen && !disposed),
|
||||
initialModuleKeys: DEFAULT_CLIENT_HOVER_MODULES,
|
||||
getCtxAgentId: () =>
|
||||
resolveOverlayCtxInspectorAgentId(
|
||||
telemetryStore.getState().telemetry,
|
||||
uiStore.getState().ctxInspectorAgentId
|
||||
),
|
||||
});
|
||||
|
||||
const hoverTipEl = h(
|
||||
@@ -2403,12 +2413,16 @@ export function mountWindowOverlay() {
|
||||
return;
|
||||
}
|
||||
|
||||
const overlayCtxAgentId = resolveOverlayCtxInspectorAgentId(
|
||||
telemetry,
|
||||
uiSt.ctxInspectorAgentId
|
||||
);
|
||||
const { agents, scopedConv: overviewScopedConv, ctxAgent, aggregated } =
|
||||
resolveScopedConversation(telemetry, 'all', uiSt.ctxInspectorAgentId);
|
||||
resolveScopedConversation(telemetry, 'all', overlayCtxAgentId);
|
||||
const { scopedConv: capsuleScopedConv } = resolveScopedConversation(
|
||||
telemetry,
|
||||
uiSt.selectedAgentScope,
|
||||
uiSt.ctxInspectorAgentId
|
||||
overlayCtxAgentId
|
||||
);
|
||||
const overviewActive = overviewScopedConv || telemetry.activeConversation || {};
|
||||
const slotCtx = buildCapsuleSlotContext(telemetry, {
|
||||
@@ -2578,11 +2592,26 @@ export function mountWindowOverlay() {
|
||||
if (currentRouteId === lastObservedRouteId) return;
|
||||
lastObservedRouteId = currentRouteId;
|
||||
const st = telemetryStore.getState();
|
||||
const activeCascadeId = String(st.telemetry?.activeConversation?.cascadeId || '').trim();
|
||||
const isSameActiveRoot =
|
||||
Boolean(activeCascadeId) &&
|
||||
Boolean(currentRouteId) &&
|
||||
currentRouteId.toLowerCase() === activeCascadeId.toLowerCase();
|
||||
const isChildOfActiveRoot =
|
||||
Boolean(currentRouteId) &&
|
||||
Boolean(resolveHostRouteMatch(st.telemetry, currentRouteId)?.isChildRoute);
|
||||
const shouldPreserveSameSession =
|
||||
!currentRouteId || isSameActiveRoot || isChildOfActiveRoot;
|
||||
const nextSelectedId =
|
||||
currentRouteId && st.selectedConversationId && st.selectedConversationId !== currentRouteId
|
||||
? ''
|
||||
: st.selectedConversationId;
|
||||
uiStore.setState({ selectedAgentScope: 'all', ctxInspectorAgentId: 'auto' });
|
||||
if (!shouldPreserveSameSession) {
|
||||
uiStore.setState({
|
||||
selectedAgentScope: 'all',
|
||||
ctxInspectorAgentId: getDefaultCtxInspectorAgentId(st.telemetry?.settings),
|
||||
});
|
||||
}
|
||||
void selectConversation(nextSelectedId, { hostRouteConversationId: currentRouteId });
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import { resolveCapsuleMetricPresentation } from '../../registries/metricRegistr
|
||||
import {
|
||||
normalizeClientTopbarSlots,
|
||||
normalizeClientWindowMountMode,
|
||||
resolveOverlayCtxInspectorAgentId,
|
||||
resolveScopedConversation,
|
||||
} from '../../store/telemetryStore.js';
|
||||
import { buildFallbackRunningConversations } from './LiveActivityWidget.js';
|
||||
@@ -536,7 +537,7 @@ export const CapsuleBarWidget = defineComponent({
|
||||
const { agents, scopedConv, ctxAgent, aggregated } = resolveScopedConversation(
|
||||
data,
|
||||
'all',
|
||||
'auto'
|
||||
resolveOverlayCtxInspectorAgentId(data, 'auto')
|
||||
);
|
||||
const slotCtx = buildCapsuleSlotContext(data, { scopedConv, ctxAgent, aggregated });
|
||||
const { runningCount, hasWaiting, multiBtnText } = resolveMultiSessionCapsuleState(data, {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
import {
|
||||
normalizeCliStatusLineSlots,
|
||||
normalizeContextAgentMode,
|
||||
normalizeFontScale,
|
||||
normalizeHoverModules,
|
||||
normalizeLanguageSetting,
|
||||
@@ -108,6 +109,7 @@ export function buildExportableSettingsJson(settings = {}) {
|
||||
cliStatusLineSlots: normalizeCliStatusLineSlots(src.cliStatusLineSlots),
|
||||
standalonePort: normalizeStandalonePort(src.standalonePort),
|
||||
showTopbarMultiSession: src.showTopbarMultiSession !== false,
|
||||
contextAgentMode: normalizeContextAgentMode(src.contextAgentMode),
|
||||
topbarCapsuleSlots: normalizeTopbarCapsuleSlots(src.topbarCapsuleSlots),
|
||||
hoverModules: normalizeHoverModules(src.hoverModules),
|
||||
overviewModules: normalizeOverviewModules(src.overviewModules),
|
||||
@@ -207,6 +209,9 @@ export function parseImportedSettingsJson(rawText) {
|
||||
if (hasKey('showTopbarMultiSession') && typeof src.showTopbarMultiSession === 'boolean') {
|
||||
patch.showTopbarMultiSession = src.showTopbarMultiSession;
|
||||
}
|
||||
if (hasKey('contextAgentMode')) {
|
||||
patch.contextAgentMode = normalizeContextAgentMode(src.contextAgentMode);
|
||||
}
|
||||
if (hasKey('topbarCapsuleSlots') && Array.isArray(src.topbarCapsuleSlots)) {
|
||||
patch.topbarCapsuleSlots = normalizeTopbarCapsuleSlots(src.topbarCapsuleSlots);
|
||||
}
|
||||
|
||||
@@ -617,6 +617,10 @@ export const I18N_MESSAGES_EN_US = Object.freeze({
|
||||
'settings.str.popoverWidthCustom': 'Custom',
|
||||
'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.contextAgentModeLabel': 'Capsule & Hover Context',
|
||||
'settings.str.contextAgentModeHint': 'Lock to Main Agent keeps the topbar percentage and hover HUD on Main Agent; you can still inspect subagents inside the full panel',
|
||||
'settings.str.contextAgentMain': 'Lock Main Agent',
|
||||
'settings.str.contextAgentAuto': 'Follow Active',
|
||||
'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})',
|
||||
|
||||
@@ -617,6 +617,10 @@ export const I18N_MESSAGES_ZH_CN = Object.freeze({
|
||||
'settings.str.popoverWidthCustom': '指定宽度',
|
||||
'settings.str.popoverWidthHint': '自适应模式下在调用明细等宽表格视图自动撑宽免水平滚动;指定宽度范围 440~1080 px',
|
||||
'settings.str.multiToggle': '实时运行会话入口',
|
||||
'settings.str.contextAgentModeLabel': '胶囊及悬浮上下文',
|
||||
'settings.str.contextAgentModeHint': '锁定主代理时,顶栏百分比及悬停速览始终展示主代理;完整面板内仍可随时点选子代理明细',
|
||||
'settings.str.contextAgentMain': '锁定主代理',
|
||||
'settings.str.contextAgentAuto': '跟随活跃',
|
||||
'settings.str.cliCapsuleToggle': 'CLI 底部状态胶囊',
|
||||
'settings.str.cliSlotsLabel': 'CLI 槽位顺序 (左 → 右,1~6 项,可拖拽)',
|
||||
'settings.str.addCliSlot': '添加 CLI 槽位 ({count}/{max})',
|
||||
|
||||
@@ -78,23 +78,33 @@ export function createDynamicWidgetHost({
|
||||
preview = false,
|
||||
isVisibleFn = () => true,
|
||||
initialModuleKeys = [],
|
||||
getCtxAgentId: customGetCtxAgentId = undefined,
|
||||
setCtxAgentId: customSetCtxAgentId = undefined,
|
||||
}) {
|
||||
const instances = new Map();
|
||||
let currentKeys = [];
|
||||
let previewCtxAgentId = 'auto';
|
||||
let previewCtxAgentId = 'main';
|
||||
let latestUpdatePayload = null;
|
||||
|
||||
const getCtxAgentId = preview ? () => previewCtxAgentId : undefined;
|
||||
const setCtxAgentId = preview
|
||||
? (nextId) => {
|
||||
previewCtxAgentId = String(nextId || 'auto');
|
||||
if (latestUpdatePayload) {
|
||||
for (const key of currentKeys) {
|
||||
instances.get(key)?.refs?.update?.(latestUpdatePayload);
|
||||
const getCtxAgentId =
|
||||
typeof customGetCtxAgentId === 'function'
|
||||
? customGetCtxAgentId
|
||||
: preview
|
||||
? () => previewCtxAgentId
|
||||
: undefined;
|
||||
const setCtxAgentId =
|
||||
typeof customSetCtxAgentId === 'function'
|
||||
? customSetCtxAgentId
|
||||
: preview
|
||||
? (nextId) => {
|
||||
previewCtxAgentId = String(nextId || 'main');
|
||||
if (latestUpdatePayload) {
|
||||
for (const key of currentKeys) {
|
||||
instances.get(key)?.refs?.update?.(latestUpdatePayload);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
: undefined;
|
||||
: undefined;
|
||||
|
||||
function syncModules(nextKeys) {
|
||||
const validKeys = [];
|
||||
|
||||
@@ -28,6 +28,7 @@ import {
|
||||
import {
|
||||
CLI_STATUSLINE_PRESETS,
|
||||
DEFAULT_CLI_STATUSLINE_SLOTS,
|
||||
DEFAULT_CONTEXT_AGENT_MODE,
|
||||
DEFAULT_HOVER_MODULES,
|
||||
DEFAULT_OVERVIEW_METRICS,
|
||||
DEFAULT_OVERVIEW_MODULES,
|
||||
@@ -42,6 +43,7 @@ import {
|
||||
STEP_TABLE_COLUMN_KEYS,
|
||||
TOPBAR_SLOT_KEYS,
|
||||
normalizeCliStatusLineSlots,
|
||||
normalizeContextAgentMode,
|
||||
normalizeHoverModules,
|
||||
normalizeModelDisplayMode,
|
||||
normalizeOrchestratorIdMode,
|
||||
@@ -444,6 +446,7 @@ function reconcileIncomingTelemetrySettings(payload, reqSettingsRev) {
|
||||
|
||||
export const CLIENT_TOPBAR_SLOT_KEYS = TOPBAR_SLOT_KEYS;
|
||||
export const DEFAULT_CLIENT_TOPBAR_SLOTS = DEFAULT_TOPBAR_SLOTS;
|
||||
export const DEFAULT_CLIENT_CONTEXT_AGENT_MODE = DEFAULT_CONTEXT_AGENT_MODE;
|
||||
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;
|
||||
@@ -464,7 +467,34 @@ export const normalizeClientPopoverWidthMode = normalizePopoverWidthMode;
|
||||
export const normalizeClientPopoverWidth = normalizePopoverWidth;
|
||||
export const normalizeClientModelDisplayMode = normalizeModelDisplayMode;
|
||||
export const normalizeClientTopbarSlots = normalizeTopbarCapsuleSlots;
|
||||
export const normalizeClientContextAgentMode = normalizeContextAgentMode;
|
||||
export const normalizeClientCliStatusLineSlots = normalizeCliStatusLineSlots;
|
||||
|
||||
/**
|
||||
* 根据偏好设置返回默认上下文代理目标(`'main'` 锁定主代理,`'auto'` 跟随活跃)。
|
||||
*
|
||||
* @param {Record<string, any>|null|undefined} settings
|
||||
* @returns {'main'|'auto'}
|
||||
*/
|
||||
export function getDefaultCtxInspectorAgentId(settings) {
|
||||
return normalizeContextAgentMode(settings?.contextAgentMode) === 'auto' ? 'auto' : 'main';
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算顶栏挂载胶囊及悬停速览浮窗应使用的上下文代理目标:
|
||||
* - 当 `contextAgentMode === 'main'`(默认)时始终锁定 `'main'`,不被后台子代理或面板临时点选带偏;
|
||||
* - 当 `contextAgentMode === 'auto'` 时跟随面板当前 `ctxInspectorAgentId`(含手动点选 `主`)。
|
||||
*
|
||||
* @param {Record<string, any>|null|undefined} telemetry
|
||||
* @param {string} [ctxInspectorAgentId='auto']
|
||||
* @returns {string}
|
||||
*/
|
||||
export function resolveOverlayCtxInspectorAgentId(telemetry, ctxInspectorAgentId = 'auto') {
|
||||
if (normalizeContextAgentMode(telemetry?.settings?.contextAgentMode) === 'main') {
|
||||
return 'main';
|
||||
}
|
||||
return ctxInspectorAgentId || 'auto';
|
||||
}
|
||||
export const resolveEffectiveClientCliStatusLineSlots = resolveEffectiveCliStatusLineSlots;
|
||||
export const normalizeClientHoverModules = normalizeHoverModules;
|
||||
export const normalizeClientOverviewModules = normalizeOverviewModules;
|
||||
@@ -558,6 +588,12 @@ export function isEquivalentTelemetry(prev, next) {
|
||||
if ((pSet?.showTopbarMultiSession !== false) !== (nSet?.showTopbarMultiSession !== false)) {
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
normalizeClientContextAgentMode(pSet?.contextAgentMode) !==
|
||||
normalizeClientContextAgentMode(nSet?.contextAgentMode)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
if (Boolean(pSet?.showStepTurnRail) !== Boolean(nSet?.showStepTurnRail)) {
|
||||
return false;
|
||||
}
|
||||
@@ -1743,6 +1779,9 @@ export async function saveSettingsPatch(patch) {
|
||||
if (Object.prototype.hasOwnProperty.call(safePatch, 'showTopbarMultiSession')) {
|
||||
safePatch.showTopbarMultiSession = Boolean(safePatch.showTopbarMultiSession);
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(safePatch, 'contextAgentMode')) {
|
||||
safePatch.contextAgentMode = normalizeClientContextAgentMode(safePatch.contextAgentMode);
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(safePatch, 'showStepTurnRail')) {
|
||||
safePatch.showStepTurnRail = Boolean(safePatch.showStepTurnRail);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ export const uiStore = createReactiveStore({
|
||||
settingsSubTab: 'general', // 'general' | 'structure' | 'account' | 'other'
|
||||
settingsStructureTab: 'mount', // 'mount' | 'hover' | 'overview' | 'steps'
|
||||
selectedAgentScope: 'all', // 'all' | 'main' | <subagent cascadeId>
|
||||
ctxInspectorAgentId: 'auto', // 'auto' | 'main' | <subagent cascadeId>
|
||||
ctxInspectorAgentId: 'main', // 'main' | 'auto' | <subagent cascadeId>
|
||||
toast: null, // { id, message, detail, actionLabel, onAction, tone, durationMs }
|
||||
});
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ import { i18nStore, isEnglishLocale, t } from '../i18n/index.js';
|
||||
import { createSvgIcon } from '../icons/SvgIcon.js';
|
||||
import { ActionMenu } from '../components/ui/ActionMenu.js';
|
||||
import {
|
||||
getDefaultCtxInspectorAgentId,
|
||||
prefetchConsumptionPresets,
|
||||
selectConsumptionTimeRange,
|
||||
selectConversation,
|
||||
@@ -1463,7 +1464,9 @@ export const ConsumptionView = defineComponent({
|
||||
activeView: 'steps',
|
||||
stepsSubTab: 'steps',
|
||||
selectedAgentScope: 'all',
|
||||
ctxInspectorAgentId: 'auto',
|
||||
ctxInspectorAgentId: getDefaultCtxInspectorAgentId(
|
||||
telemetryStore.getState().telemetry?.settings
|
||||
),
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
@@ -56,6 +56,7 @@ import { ActionMenu } from '../components/ui/ActionMenu.js';
|
||||
import { getEffectiveLocale, i18nStore, t } from '../i18n/index.js';
|
||||
import {
|
||||
formatAgentLabel,
|
||||
getDefaultCtxInspectorAgentId,
|
||||
normalizeClientStepColumns,
|
||||
normalizeClientStepTokenComboFormat,
|
||||
resolveScopedConversation,
|
||||
@@ -274,9 +275,18 @@ export const StepsDetailView = defineComponent({
|
||||
const prevUiScope = uiStore.getState().selectedAgentScope;
|
||||
lastSyncedUiScope = mappedSingle;
|
||||
if (prevUiScope !== mappedSingle) {
|
||||
const curCtxId = uiStore.getState().ctxInspectorAgentId;
|
||||
const shouldResetSubCtx =
|
||||
mappedSingle === 'all' && curCtxId && curCtxId !== 'main' && curCtxId !== 'auto';
|
||||
uiStore.setState({
|
||||
selectedAgentScope: mappedSingle,
|
||||
...(mappedSingle === 'all' ? { ctxInspectorAgentId: 'auto' } : {}),
|
||||
...(shouldResetSubCtx
|
||||
? {
|
||||
ctxInspectorAgentId: getDefaultCtxInspectorAgentId(
|
||||
telemetryStore.getState().telemetry?.settings
|
||||
),
|
||||
}
|
||||
: {}),
|
||||
});
|
||||
} else if (latestSlice) {
|
||||
renderStepsData(latestSlice);
|
||||
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
getOverviewModuleOptions,
|
||||
} from '../../registries/widgetRegistry.js';
|
||||
import {
|
||||
DEFAULT_CLIENT_CONTEXT_AGENT_MODE,
|
||||
DEFAULT_CLIENT_HOVER_MODULES,
|
||||
DEFAULT_CLIENT_OVERVIEW_METRICS,
|
||||
DEFAULT_CLIENT_OVERVIEW_MODULES,
|
||||
@@ -30,6 +31,7 @@ import {
|
||||
MAX_CLIENT_POPOVER_WIDTH,
|
||||
MIN_CLIENT_POPOVER_WIDTH,
|
||||
normalizeClientCliStatusLineSlots,
|
||||
normalizeClientContextAgentMode,
|
||||
normalizeClientHoverModules,
|
||||
normalizeClientOverviewMetrics,
|
||||
normalizeClientOverviewModules,
|
||||
@@ -40,6 +42,7 @@ import {
|
||||
normalizeClientTopbarSlots,
|
||||
normalizeClientWindowMountMode,
|
||||
resolveEffectiveClientCliStatusLineSlots,
|
||||
resolveOverlayCtxInspectorAgentId,
|
||||
saveSettingsPatch,
|
||||
triggerCliStatusLineAction,
|
||||
} from '../../store/telemetryStore.js';
|
||||
@@ -95,6 +98,13 @@ function getPopoverWidthModeOptions() {
|
||||
];
|
||||
}
|
||||
|
||||
function getContextAgentModeOptions() {
|
||||
return [
|
||||
{ value: 'main', label: t('settings.str.contextAgentMain') },
|
||||
{ value: 'auto', label: t('settings.str.contextAgentAuto') },
|
||||
];
|
||||
}
|
||||
|
||||
function isSameList(a, b) {
|
||||
if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) return false;
|
||||
for (let i = 0; i < a.length; i += 1) {
|
||||
@@ -185,6 +195,7 @@ export const SettingsStructureTab = defineComponent({
|
||||
let draftEnableCliStatusLine = true;
|
||||
let draftCliStatusLineSlots = null;
|
||||
let draftShowTopbarMulti = true;
|
||||
let draftContextAgentMode = DEFAULT_CLIENT_CONTEXT_AGENT_MODE;
|
||||
let draftTopbarSlots = [...DEFAULT_CLIENT_TOPBAR_SLOTS];
|
||||
let draftHoverModules = [...DEFAULT_CLIENT_HOVER_MODULES];
|
||||
let draftOverviewModules = [...DEFAULT_CLIENT_OVERVIEW_MODULES];
|
||||
@@ -221,6 +232,7 @@ export const SettingsStructureTab = defineComponent({
|
||||
popoverWidth: draftPopoverWidth,
|
||||
enableCliStatusLine: draftEnableCliStatusLine,
|
||||
showTopbarMultiSession: draftShowTopbarMulti,
|
||||
contextAgentMode: draftContextAgentMode,
|
||||
topbarCapsuleSlots: draftTopbarSlots,
|
||||
hoverModules: draftHoverModules,
|
||||
overviewModules: draftOverviewModules,
|
||||
@@ -336,6 +348,14 @@ export const SettingsStructureTab = defineComponent({
|
||||
className: 'form-label',
|
||||
text: t('settings.str.multiToggle'),
|
||||
});
|
||||
const contextAgentModeLabelEl = h('span', {
|
||||
className: 'form-label',
|
||||
text: t('settings.str.contextAgentModeLabel'),
|
||||
});
|
||||
const contextAgentModeHintEl = h('span', {
|
||||
className: 'settings-hint-text',
|
||||
text: t('settings.str.contextAgentModeHint'),
|
||||
});
|
||||
const cliCapsuleLabelEl = h('span', {
|
||||
className: 'form-label',
|
||||
text: t('settings.str.cliCapsuleToggle'),
|
||||
@@ -457,6 +477,22 @@ export const SettingsStructureTab = defineComponent({
|
||||
},
|
||||
});
|
||||
|
||||
const contextAgentModeToggle = SegmentedControl({
|
||||
ariaLabel: t('settings.str.contextAgentModeLabel'),
|
||||
modelValue: draftContextAgentMode,
|
||||
options: getContextAgentModeOptions(),
|
||||
onUpdateModelValue: (val) => {
|
||||
const nextMode = normalizeClientContextAgentMode(val);
|
||||
draftContextAgentMode = nextMode;
|
||||
uiStore.setState({ ctxInspectorAgentId: nextMode });
|
||||
syncMountSectionMeta();
|
||||
props.onLayoutChange?.();
|
||||
void persistStructurePatch(mountSection, {
|
||||
contextAgentMode: nextMode,
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
const cliCapsuleToggle = SegmentedControl({
|
||||
ariaLabel: t('settings.str.cliCapsuleToggle'),
|
||||
modelValue: 'on',
|
||||
@@ -574,7 +610,9 @@ export const SettingsStructureTab = defineComponent({
|
||||
draftEnableCliStatusLine = true;
|
||||
draftCliStatusLineSlots = null;
|
||||
draftShowTopbarMulti = true;
|
||||
draftContextAgentMode = DEFAULT_CLIENT_CONTEXT_AGENT_MODE;
|
||||
draftTopbarSlots = [...DEFAULT_CLIENT_TOPBAR_SLOTS];
|
||||
uiStore.setState({ ctxInspectorAgentId: DEFAULT_CLIENT_CONTEXT_AGENT_MODE });
|
||||
syncMountSectionMeta();
|
||||
props.onLayoutChange?.();
|
||||
void persistStructurePatch(
|
||||
@@ -587,6 +625,7 @@ export const SettingsStructureTab = defineComponent({
|
||||
enableCliStatusLine: true,
|
||||
cliStatusLineSlots: null,
|
||||
showTopbarMultiSession: true,
|
||||
contextAgentMode: DEFAULT_CLIENT_CONTEXT_AGENT_MODE,
|
||||
topbarCapsuleSlots: [...DEFAULT_CLIENT_TOPBAR_SLOTS],
|
||||
},
|
||||
'settings.resetDone'
|
||||
@@ -611,6 +650,13 @@ export const SettingsStructureTab = defineComponent({
|
||||
multiToggleLabelEl,
|
||||
multiSessionToggle.el,
|
||||
]),
|
||||
h('div', { className: 'form-row' }, [
|
||||
h('div', { className: 'settings-inline-row' }, [
|
||||
contextAgentModeLabelEl,
|
||||
contextAgentModeToggle.el,
|
||||
]),
|
||||
contextAgentModeHintEl,
|
||||
]),
|
||||
h('div', { className: 'form-row' }, [capsuleSlotsLabelEl, topbarSlotsList.el]),
|
||||
cliStatusGroupEl,
|
||||
],
|
||||
@@ -677,6 +723,11 @@ export const SettingsStructureTab = defineComponent({
|
||||
modelValue: draftShowTopbarMulti ? 'show' : 'hide',
|
||||
options: getMultiToggleOptions(),
|
||||
});
|
||||
contextAgentModeToggle.setProps({
|
||||
modelValue: draftContextAgentMode,
|
||||
options: getContextAgentModeOptions(),
|
||||
ariaLabel: t('settings.str.contextAgentModeLabel'),
|
||||
});
|
||||
const cliInstalled = Boolean(latestCliStatusLine?.installed);
|
||||
patchAttr(cliStatusGroupEl, 'hidden', !cliInstalled);
|
||||
cliCapsuleToggle.setProps({
|
||||
@@ -739,6 +790,7 @@ export const SettingsStructureTab = defineComponent({
|
||||
draftEnableCliStatusLine === true &&
|
||||
draftCliStatusLineSlots === null &&
|
||||
draftShowTopbarMulti === true &&
|
||||
draftContextAgentMode === DEFAULT_CLIENT_CONTEXT_AGENT_MODE &&
|
||||
isSameList(draftTopbarSlots, DEFAULT_CLIENT_TOPBAR_SLOTS);
|
||||
mountSection.refs.setResetDisabled(isDefault);
|
||||
refreshMountPreview();
|
||||
@@ -760,6 +812,11 @@ export const SettingsStructureTab = defineComponent({
|
||||
preview: true,
|
||||
isVisibleFn: () => isStructureVisible() && activeThirdTab === 'hover',
|
||||
initialModuleKeys: [],
|
||||
getCtxAgentId: () =>
|
||||
resolveOverlayCtxInspectorAgentId(
|
||||
{ settings: { contextAgentMode: draftContextAgentMode } },
|
||||
'auto'
|
||||
),
|
||||
});
|
||||
const hoverPreviewCanvas = h('div', { className: 'structure-preview-canvas' }, [
|
||||
hoverPreviewTipEl,
|
||||
@@ -1348,6 +1405,7 @@ export const SettingsStructureTab = defineComponent({
|
||||
draftEnableCliStatusLine = settings.enableCliStatusLine !== false;
|
||||
draftCliStatusLineSlots = normalizeClientCliStatusLineSlots(settings.cliStatusLineSlots);
|
||||
draftShowTopbarMulti = settings.showTopbarMultiSession !== false;
|
||||
draftContextAgentMode = normalizeClientContextAgentMode(settings.contextAgentMode);
|
||||
draftTopbarSlots = normalizeClientTopbarSlots(settings.topbarCapsuleSlots);
|
||||
draftHoverModules = normalizeClientHoverModules(settings.hoverModules);
|
||||
draftOverviewModules = normalizeClientOverviewModules(settings.overviewModules);
|
||||
@@ -1381,6 +1439,8 @@ export const SettingsStructureTab = defineComponent({
|
||||
patchText(popoverWidthHintEl, t('settings.str.popoverWidthHint'));
|
||||
popoverWidthStepper.setProps({ ariaLabel: t('settings.str.popoverWidthLabel') });
|
||||
patchText(multiToggleLabelEl, t('settings.str.multiToggle'));
|
||||
patchText(contextAgentModeLabelEl, t('settings.str.contextAgentModeLabel'));
|
||||
patchText(contextAgentModeHintEl, t('settings.str.contextAgentModeHint'));
|
||||
patchText(cliCapsuleLabelEl, t('settings.str.cliCapsuleToggle'));
|
||||
patchText(cliSlotsLabelEl, t('settings.str.cliSlotsLabel'));
|
||||
patchText(capsuleSlotsLabelEl, t('settings.str.capsuleSlotsLabel'));
|
||||
@@ -1454,6 +1514,7 @@ export const SettingsStructureTab = defineComponent({
|
||||
popoverWidthStepper.destroy();
|
||||
popoverWidthModeToggle.destroy();
|
||||
multiSessionToggle.destroy();
|
||||
contextAgentModeToggle.destroy();
|
||||
cliCapsuleToggle.destroy();
|
||||
cliSlotsList.destroy();
|
||||
topbarSlotsList.destroy();
|
||||
@@ -1482,6 +1543,7 @@ export const SettingsStructureTab = defineComponent({
|
||||
stepTablePreview,
|
||||
windowMountSelect,
|
||||
multiSessionToggle,
|
||||
contextAgentModeToggle,
|
||||
cliCapsuleToggle,
|
||||
cliStatusGroupEl,
|
||||
cliStatusDetailEl,
|
||||
|
||||
Reference in New Issue
Block a user