mirror of
https://github.com/lWolvesl/antigravity-usage-monitor.git
synced 2026-11-26 17:09:28 +08:00
feat(panel): subagent monitoring and 10-channel context window (v1.4.1)
This commit is contained in:
@@ -1,20 +1,37 @@
|
||||
/**
|
||||
* @fileoverview 6-channel segmented context window progress bar updated via
|
||||
* CSS custom variables against the current model's automatic compaction baseline.
|
||||
* @fileoverview 10-channel segmented context window progress bar updated via
|
||||
* CSS custom variables against the current model's automatic compaction baseline,
|
||||
* dynamically ordered from largest to smallest segment.
|
||||
*/
|
||||
|
||||
import { defineComponent } from '../../core/component.js';
|
||||
import { h, patchAttr, patchStyleVar } from '../../core/domPatch.js';
|
||||
|
||||
const SEGMENT_DEFS = [
|
||||
{ key: 'assistant', cls: 'seg-assistant', getVal: (c) => Number(c.assistantTokens || 0) },
|
||||
{ key: 'toolResults', cls: 'seg-tool-results', getVal: (c) => Number(c.toolResultsTokens || 0) },
|
||||
{
|
||||
key: 'userInput',
|
||||
cls: 'seg-user-input',
|
||||
getVal: (c) => Number(c.userInputTokens ?? c.messagesTokens ?? 0),
|
||||
},
|
||||
{ key: 'subagent', cls: 'seg-subagent-msg', getVal: (c) => Number(c.subagentTokens || 0) },
|
||||
{ key: 'checkpoint', cls: 'seg-checkpoint', getVal: (c) => Number(c.checkpointTokens || 0) },
|
||||
{ key: 'systemPrompt', cls: 'seg-system-prompt', getVal: (c) => Number(c.systemPromptTokens || 0) },
|
||||
{ key: 'systemTools', cls: 'seg-system-tools', getVal: (c) => Number(c.systemToolsTokens || 0) },
|
||||
{ key: 'mcpTools', cls: 'seg-mcp-tools', getVal: (c) => Number(c.mcpToolsTokens || 0) },
|
||||
{ key: 'skills', cls: 'seg-skills', getVal: (c) => Number(c.skillsTokens || 0) },
|
||||
{ key: 'userRules', cls: 'seg-user-rules', getVal: (c) => Number(c.userRulesTokens || 0) },
|
||||
];
|
||||
|
||||
export const ContextSegmentMeter = defineComponent({
|
||||
name: 'ContextSegmentMeter',
|
||||
setup({ getProps }) {
|
||||
const segMessages = h('div', { className: 'progress-seg seg-messages' });
|
||||
const segSystemTools = h('div', { className: 'progress-seg seg-system-tools' });
|
||||
const segMcpTools = h('div', { className: 'progress-seg seg-mcp-tools' });
|
||||
const segSkills = h('div', { className: 'progress-seg seg-skills' });
|
||||
const segSystemPrompt = h('div', { className: 'progress-seg seg-system-prompt' });
|
||||
const segUserRules = h('div', { className: 'progress-seg seg-user-rules' });
|
||||
const segments = SEGMENT_DEFS.map((def, idx) => ({
|
||||
...def,
|
||||
defaultOrder: idx,
|
||||
el: h('div', { className: `progress-seg ${def.cls}` }),
|
||||
}));
|
||||
|
||||
const trackEl = h(
|
||||
'div',
|
||||
@@ -24,25 +41,30 @@ export const ContextSegmentMeter = defineComponent({
|
||||
'aria-valuemin': '0',
|
||||
'aria-valuemax': '100',
|
||||
},
|
||||
[segMessages, segSystemTools, segMcpTools, segSkills, segSystemPrompt, segUserRules]
|
||||
segments.map((s) => s.el)
|
||||
);
|
||||
|
||||
let lastOrderSig = segments.map((s) => s.key).join(',');
|
||||
|
||||
function syncMeter() {
|
||||
const ctx = getProps().context || {};
|
||||
const limit = Math.max(1, Number(ctx.compactionLimitTokens || ctx.limitTokens || 256000));
|
||||
const pctMessages = Math.min(100, ((ctx.messagesTokens || 0) / limit) * 100);
|
||||
const pctSystemTools = Math.min(100, ((ctx.systemToolsTokens || 0) / limit) * 100);
|
||||
const pctMcpTools = Math.min(100, ((ctx.mcpToolsTokens || 0) / limit) * 100);
|
||||
const pctSkills = Math.min(100, ((ctx.skillsTokens || 0) / limit) * 100);
|
||||
const pctSystemPrompt = Math.min(100, ((ctx.systemPromptTokens || 0) / limit) * 100);
|
||||
const pctUserRules = Math.min(100, ((ctx.userRulesTokens || 0) / limit) * 100);
|
||||
const scored = segments.map((seg) => {
|
||||
const val = seg.getVal(ctx);
|
||||
const pct = Math.min(100, (val / limit) * 100);
|
||||
patchStyleVar(seg.el, '--seg-w', `${pct.toFixed(2)}%`);
|
||||
return { seg, val };
|
||||
});
|
||||
|
||||
scored.sort((a, b) => b.val - a.val || a.seg.defaultOrder - b.seg.defaultOrder);
|
||||
const nextOrderSig = scored.map((x) => x.seg.key).join(',');
|
||||
if (nextOrderSig !== lastOrderSig) {
|
||||
lastOrderSig = nextOrderSig;
|
||||
for (const { seg } of scored) {
|
||||
trackEl.appendChild(seg.el);
|
||||
}
|
||||
}
|
||||
|
||||
patchStyleVar(segMessages, '--seg-w', `${pctMessages.toFixed(2)}%`);
|
||||
patchStyleVar(segSystemTools, '--seg-w', `${pctSystemTools.toFixed(2)}%`);
|
||||
patchStyleVar(segMcpTools, '--seg-w', `${pctMcpTools.toFixed(2)}%`);
|
||||
patchStyleVar(segSkills, '--seg-w', `${pctSkills.toFixed(2)}%`);
|
||||
patchStyleVar(segSystemPrompt, '--seg-w', `${pctSystemPrompt.toFixed(2)}%`);
|
||||
patchStyleVar(segUserRules, '--seg-w', `${pctUserRules.toFixed(2)}%`);
|
||||
patchAttr(trackEl, 'aria-valuenow', Math.round(ctx.compactionUsedPct ?? ctx.usedPct ?? 0));
|
||||
}
|
||||
|
||||
@@ -50,14 +72,7 @@ export const ContextSegmentMeter = defineComponent({
|
||||
|
||||
return {
|
||||
el: trackEl,
|
||||
refs: {
|
||||
segMessages,
|
||||
segSystemTools,
|
||||
segMcpTools,
|
||||
segSkills,
|
||||
segSystemPrompt,
|
||||
segUserRules,
|
||||
},
|
||||
refs: { segments },
|
||||
onPropsChange: syncMeter,
|
||||
};
|
||||
},
|
||||
|
||||
@@ -13,7 +13,9 @@ export const CustomSelect = defineComponent({
|
||||
let isOpen = false;
|
||||
let focusedIndex = -1;
|
||||
|
||||
const leadIcon = createSvgIcon(getProps().icon || 'bolt', { size: 13 });
|
||||
const initialIcon = getProps().icon;
|
||||
const leadIcon = createSvgIcon(initialIcon || 'bolt', { size: 13 });
|
||||
patchAttr(leadIcon, 'hidden', !initialIcon);
|
||||
const triggerLabel = h('span', { className: 'select-label' });
|
||||
const chevronIcon = createSvgIcon('chevron-down', { size: 13 });
|
||||
|
||||
@@ -40,7 +42,8 @@ export const CustomSelect = defineComponent({
|
||||
hidden: true,
|
||||
});
|
||||
|
||||
const rootEl = h('div', { className: 'custom-select' }, [triggerBtn, menuEl]);
|
||||
const initialClass = ['custom-select', getProps().className].filter(Boolean).join(' ');
|
||||
const rootEl = h('div', { className: initialClass }, [triggerBtn, menuEl]);
|
||||
|
||||
function toggleOpen(nextOpen) {
|
||||
isOpen = Boolean(nextOpen);
|
||||
@@ -142,9 +145,16 @@ export const CustomSelect = defineComponent({
|
||||
}
|
||||
|
||||
function syncTriggerAndMenu() {
|
||||
const { options = [], modelValue, placeholder = '请选择', icon = 'bolt' } = getProps();
|
||||
patchSvgIcon(leadIcon, icon);
|
||||
const selectedOpt = options.find((o) => o.value === modelValue) || options[0];
|
||||
const { options = [], modelValue, placeholder = '请选择', icon } = getProps();
|
||||
patchAttr(leadIcon, 'hidden', !icon);
|
||||
if (icon) {
|
||||
patchSvgIcon(leadIcon, icon);
|
||||
}
|
||||
const selectedOpt =
|
||||
options.find((o) => o.value === modelValue) ||
|
||||
(modelValue !== '' && modelValue !== null && modelValue !== undefined
|
||||
? options[0]
|
||||
: undefined);
|
||||
patchText(triggerLabel, selectedOpt ? selectedOpt.label : placeholder);
|
||||
if (isOpen) {
|
||||
renderMenuOptions();
|
||||
|
||||
Reference in New Issue
Block a user