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:
@@ -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, {
|
||||
|
||||
Reference in New Issue
Block a user