mirror of
https://github.com/lWolvesl/antigravity-usage-monitor.git
synced 2026-11-26 17:09:28 +08:00
feat(panel): add experimental modern UI, sliding switchers, cycle range, and fluid animations
This commit is contained in:
@@ -783,6 +783,7 @@ export function createSessionLineChart() {
|
||||
clearHover();
|
||||
return;
|
||||
}
|
||||
const wasHidden = tooltipEl.hasAttribute('hidden');
|
||||
hoveredIdx = idx;
|
||||
const pt = currentPoints[idx];
|
||||
patchAttr(hoverLine, 'hidden', false);
|
||||
@@ -813,6 +814,20 @@ export function createSessionLineChart() {
|
||||
const clampedPct = Math.max(1, Math.min(99, rawPct));
|
||||
patchStyleVar(tooltipEl, '--tip-x', `${clampedPct.toFixed(1)}%`);
|
||||
patchStyleVar(tooltipEl, '--tip-shift', `-${clampedPct.toFixed(1)}%`);
|
||||
patchStyleVar(tooltipEl, '--tip-y', '0px');
|
||||
if (wasHidden) {
|
||||
patchClasses(tooltipEl, { 'is-tracking': false });
|
||||
void tooltipEl.offsetWidth;
|
||||
if (typeof window !== 'undefined' && typeof window.requestAnimationFrame === 'function') {
|
||||
window.requestAnimationFrame(() => {
|
||||
if (!tooltipEl.hasAttribute('hidden')) {
|
||||
patchClasses(tooltipEl, { 'is-tracking': true });
|
||||
}
|
||||
});
|
||||
} else {
|
||||
patchClasses(tooltipEl, { 'is-tracking': true });
|
||||
}
|
||||
}
|
||||
|
||||
for (const [tIdx, el] of tickElsByIdx.entries()) {
|
||||
patchClasses(el, { 'is-hovered': tIdx === idx });
|
||||
@@ -824,6 +839,7 @@ export function createSessionLineChart() {
|
||||
patchAttr(hoverLine, 'hidden', true);
|
||||
patchAttr(hoverDot, 'hidden', true);
|
||||
patchAttr(tooltipEl, 'hidden', true);
|
||||
patchClasses(tooltipEl, { 'is-tracking': false });
|
||||
if (currentPoints.some((p) => p.valid)) {
|
||||
patchAttr(peakPill, 'hidden', false);
|
||||
}
|
||||
@@ -1577,6 +1593,7 @@ export function createModelFitChart() {
|
||||
patchAttr(hoverRawDot, 'cx', sp.x.toFixed(1));
|
||||
patchAttr(hoverRawDot, 'cy', sp.rawY.toFixed(1));
|
||||
|
||||
const wasHidden = tooltipEl.hasAttribute('hidden');
|
||||
patchAttr(tooltipEl, 'hidden', false);
|
||||
patchText(tipHeadLeft, sp.stepTag);
|
||||
patchText(tipHeadRight, sp.modelText);
|
||||
@@ -1612,6 +1629,20 @@ export function createModelFitChart() {
|
||||
const clampedPct = Math.max(1, Math.min(99, rawPct));
|
||||
patchStyleVar(tooltipEl, '--tip-x', `${clampedPct.toFixed(1)}%`);
|
||||
patchStyleVar(tooltipEl, '--tip-shift', `-${clampedPct.toFixed(1)}%`);
|
||||
patchStyleVar(tooltipEl, '--tip-y', '0px');
|
||||
if (wasHidden) {
|
||||
patchClasses(tooltipEl, { 'is-tracking': false });
|
||||
void tooltipEl.offsetWidth;
|
||||
if (typeof window !== 'undefined' && typeof window.requestAnimationFrame === 'function') {
|
||||
window.requestAnimationFrame(() => {
|
||||
if (!tooltipEl.hasAttribute('hidden')) {
|
||||
patchClasses(tooltipEl, { 'is-tracking': true });
|
||||
}
|
||||
});
|
||||
} else {
|
||||
patchClasses(tooltipEl, { 'is-tracking': true });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function clearHover() {
|
||||
@@ -1620,6 +1651,7 @@ export function createModelFitChart() {
|
||||
patchAttr(hoverFitDot, 'hidden', true);
|
||||
patchAttr(hoverRawDot, 'hidden', true);
|
||||
patchAttr(tooltipEl, 'hidden', true);
|
||||
patchClasses(tooltipEl, { 'is-tracking': false });
|
||||
}
|
||||
|
||||
plotStage.addEventListener('mousemove', (e) => {
|
||||
|
||||
@@ -403,6 +403,34 @@ export function createTrendAreaChart() {
|
||||
let hoveredIdx = -1;
|
||||
let hoveredCellEl = null;
|
||||
let lastRenderSig = '';
|
||||
let tipTrackRaf = 0;
|
||||
|
||||
function cancelTipTrackRaf() {
|
||||
if (tipTrackRaf && typeof window !== 'undefined' && typeof window.cancelAnimationFrame === 'function') {
|
||||
window.cancelAnimationFrame(tipTrackRaf);
|
||||
}
|
||||
tipTrackRaf = 0;
|
||||
}
|
||||
|
||||
function armTooltipTracking(wasHidden) {
|
||||
if (!wasHidden) return;
|
||||
patchClasses(tooltipEl, { 'is-tracking': false });
|
||||
patchClasses(hoverDot, { 'is-tracking': false });
|
||||
void tooltipEl.offsetWidth;
|
||||
cancelTipTrackRaf();
|
||||
if (typeof window !== 'undefined' && typeof window.requestAnimationFrame === 'function') {
|
||||
tipTrackRaf = window.requestAnimationFrame(() => {
|
||||
tipTrackRaf = 0;
|
||||
if (!tooltipEl.hasAttribute('hidden')) {
|
||||
patchClasses(tooltipEl, { 'is-tracking': true });
|
||||
patchClasses(hoverDot, { 'is-tracking': true });
|
||||
}
|
||||
});
|
||||
} else {
|
||||
patchClasses(tooltipEl, { 'is-tracking': true });
|
||||
patchClasses(hoverDot, { 'is-tracking': true });
|
||||
}
|
||||
}
|
||||
|
||||
function populateTooltipContent(slot) {
|
||||
patchText(tipTimeEl, slot.fullLabel || slot.label || '--');
|
||||
@@ -458,6 +486,7 @@ export function createTrendAreaChart() {
|
||||
clearHover();
|
||||
return;
|
||||
}
|
||||
const wasHidden = tooltipEl.hasAttribute('hidden');
|
||||
hoveredIdx = idx;
|
||||
const slot = currentSlots[idx];
|
||||
const pt = currentPts[idx];
|
||||
@@ -470,19 +499,31 @@ export function createTrendAreaChart() {
|
||||
patchAttr(hoverDot, 'cx', pt.x.toFixed(1));
|
||||
patchAttr(hoverDot, 'cy', pt.y.toFixed(1));
|
||||
|
||||
const isLineLow = pt.y < Math.round((TOP_Y + BOTTOM_Y) / 2);
|
||||
patchAttr(peakPill, 'hidden', true);
|
||||
patchClasses(tooltipEl, {
|
||||
'is-hm-bottom': false,
|
||||
'is-hm-top': false,
|
||||
'is-line-low': pt.y < Math.round((TOP_Y + BOTTOM_Y) / 2),
|
||||
'is-line-low': isLineLow,
|
||||
});
|
||||
patchAttr(tooltipEl, 'hidden', false);
|
||||
populateTooltipContent(slot);
|
||||
|
||||
let tipY = 0;
|
||||
if (isLineLow) {
|
||||
const wrapH = Number(chartWrap.offsetHeight || 0);
|
||||
const tipH = Number(tooltipEl.offsetHeight || 0);
|
||||
if (wrapH > 0 && tipH > 0) {
|
||||
tipY = Math.max(0, wrapH - tipH - 22);
|
||||
}
|
||||
}
|
||||
|
||||
const rawPct = (pt.x / viewW) * 100;
|
||||
const clampedPct = Math.max(1, Math.min(99, rawPct));
|
||||
patchStyleVar(tooltipEl, '--tip-x', `${clampedPct.toFixed(1)}%`);
|
||||
patchStyleVar(tooltipEl, '--tip-shift', `-${clampedPct.toFixed(1)}%`);
|
||||
patchStyleVar(tooltipEl, '--tip-y', `${Math.round(tipY)}px`);
|
||||
armTooltipTracking(wasHidden);
|
||||
|
||||
for (const [tIdx, el] of tickElsByIdx.entries()) {
|
||||
patchClasses(el, { 'is-hovered': tIdx === idx });
|
||||
@@ -510,6 +551,7 @@ export function createTrendAreaChart() {
|
||||
const row = Number(targetCell.getAttribute('data-hm-row') || 0);
|
||||
const col = Number(targetCell.getAttribute('data-hm-col') || 0);
|
||||
|
||||
const wasHidden = tooltipEl.hasAttribute('hidden');
|
||||
// 上半区(周一~周四)浮层停靠热力图下方,下半区(周五~周日)停靠热力图上方,互不遮挡被悬停格子且永不越界裁剪
|
||||
patchClasses(tooltipEl, {
|
||||
'is-hm-bottom': row <= 3,
|
||||
@@ -536,14 +578,23 @@ export function createTrendAreaChart() {
|
||||
const clampedPct = Math.max(1, Math.min(99, rawPct));
|
||||
patchStyleVar(tooltipEl, '--tip-x', `${clampedPct.toFixed(1)}%`);
|
||||
patchStyleVar(tooltipEl, '--tip-shift', `-${clampedPct.toFixed(1)}%`);
|
||||
patchStyleVar(tooltipEl, '--tip-y', '0px');
|
||||
armTooltipTracking(wasHidden);
|
||||
}
|
||||
|
||||
function clearHover() {
|
||||
cancelTipTrackRaf();
|
||||
hoveredIdx = -1;
|
||||
patchAttr(hoverLine, 'hidden', true);
|
||||
patchAttr(hoverDot, 'hidden', true);
|
||||
patchAttr(tooltipEl, 'hidden', true);
|
||||
patchClasses(tooltipEl, { 'is-hm-bottom': false, 'is-hm-top': false, 'is-line-low': false });
|
||||
patchClasses(tooltipEl, {
|
||||
'is-hm-bottom': false,
|
||||
'is-hm-top': false,
|
||||
'is-line-low': false,
|
||||
'is-tracking': false,
|
||||
});
|
||||
patchClasses(hoverDot, { 'is-tracking': false });
|
||||
if (!currentIsHeatmap) {
|
||||
patchAttr(peakPill, 'hidden', false);
|
||||
}
|
||||
@@ -755,6 +806,7 @@ export function createTrendAreaChart() {
|
||||
}
|
||||
|
||||
function destroy() {
|
||||
cancelTipTrackRaf();
|
||||
resizeObs?.disconnect();
|
||||
resizeObs = null;
|
||||
if (onWinResize && typeof window !== 'undefined' && typeof window.removeEventListener === 'function') {
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
PANEL_SCALE_FACTORS,
|
||||
applyAppearanceToRoot,
|
||||
normalizeClientFontScale,
|
||||
normalizeClientModernUi,
|
||||
} from '../../core/appearance.js';
|
||||
import {
|
||||
h,
|
||||
@@ -1397,6 +1398,7 @@ export function mountWindowOverlay() {
|
||||
onSelectSession: inspectSessionInMonitor,
|
||||
onLayoutChange: () => {
|
||||
if (multiOpen) {
|
||||
patchClasses(multiPanelEl, { 'is-instant': true });
|
||||
positionFloatingElements();
|
||||
}
|
||||
},
|
||||
@@ -1454,9 +1456,23 @@ export function mountWindowOverlay() {
|
||||
applyAppearanceToRoot(capsuleHost, settings, { includeFontScale: false });
|
||||
applyAppearanceToRoot(portalHost, settings, { includeFontScale: true });
|
||||
const scaleKey = normalizeClientFontScale(settings?.fontScale);
|
||||
popoverEl.setAttribute?.('data-font-scale', scaleKey);
|
||||
hoverTipEl.setAttribute?.('data-font-scale', scaleKey);
|
||||
multiPanelEl.setAttribute?.('data-font-scale', scaleKey);
|
||||
const isModernUi = normalizeClientModernUi(settings?.experimentalModernUi);
|
||||
const colorScheme = portalHost.getAttribute?.('data-color-scheme') || 'light';
|
||||
for (const el of [popoverEl, hoverTipEl, multiPanelEl]) {
|
||||
if (el.getAttribute?.('data-font-scale') !== scaleKey) {
|
||||
el.setAttribute?.('data-font-scale', scaleKey);
|
||||
}
|
||||
if (el.getAttribute?.('data-color-scheme') !== colorScheme) {
|
||||
el.setAttribute?.('data-color-scheme', colorScheme);
|
||||
}
|
||||
if (isModernUi) {
|
||||
if (el.getAttribute?.('data-modern-ui') !== 'true') {
|
||||
el.setAttribute?.('data-modern-ui', 'true');
|
||||
}
|
||||
} else if (el.hasAttribute?.('data-modern-ui')) {
|
||||
el.removeAttribute?.('data-modern-ui');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
portalShadow.appendChild(multiPanelEl);
|
||||
@@ -1591,6 +1607,7 @@ export function mountWindowOverlay() {
|
||||
|
||||
function ensureWorkbenchThemeObserved() {
|
||||
const wb = syncWorkbenchThemeVars();
|
||||
syncPortalAppearance(telemetryStore.getState().telemetry?.settings);
|
||||
if (wb && wb !== observedWorkbench && themeObserver) {
|
||||
observedWorkbench = wb;
|
||||
try {
|
||||
@@ -2620,6 +2637,7 @@ export function mountWindowOverlay() {
|
||||
if (typeof MutationObserver !== 'undefined') {
|
||||
themeObserver = new MutationObserver(() => {
|
||||
syncWorkbenchThemeVars();
|
||||
syncPortalAppearance(telemetryStore.getState().telemetry?.settings);
|
||||
});
|
||||
if (document.head) {
|
||||
themeObserver.observe(document.head, {
|
||||
@@ -2628,6 +2646,18 @@ export function mountWindowOverlay() {
|
||||
subtree: true,
|
||||
});
|
||||
}
|
||||
if (document.documentElement) {
|
||||
themeObserver.observe(document.documentElement, {
|
||||
attributes: true,
|
||||
attributeFilter: ['class', 'style', 'data-theme', 'data-vscode-theme-kind'],
|
||||
});
|
||||
}
|
||||
if (document.body) {
|
||||
themeObserver.observe(document.body, {
|
||||
attributes: true,
|
||||
attributeFilter: ['class', 'style', 'data-theme', 'data-vscode-theme-kind'],
|
||||
});
|
||||
}
|
||||
if (document.body) {
|
||||
hostDomObserver = new MutationObserver((records) => {
|
||||
if (
|
||||
|
||||
@@ -1,54 +1,215 @@
|
||||
/**
|
||||
* @fileoverview Micro-bezel (2px radius) SegmentedControl switcher
|
||||
* for time-range filtering, context limit selection, and sub-table switching.
|
||||
* @fileoverview Sliding SegmentedControl switcher with variable-width GPU glider.
|
||||
* Measures active button geometry via ResizeObserver so both inline variable-width
|
||||
* segments (e.g. "今天 / 1天 / ... / 自定义", "按步查看 (1520) / 总汇总") and equal-width
|
||||
* grid bars ("常规 / 结构 / 其他") glide smoothly without stretching from 0px on tab reveal.
|
||||
*/
|
||||
|
||||
import { defineComponent } from '../../core/component.js';
|
||||
import { h, patchAttr, patchClasses, patchKeyedList, patchText } from '../../core/domPatch.js';
|
||||
import { h, patchAttr, patchClasses, patchStyleVar, patchText } from '../../core/domPatch.js';
|
||||
|
||||
export const SegmentedControl = defineComponent({
|
||||
name: 'SegmentedControl',
|
||||
setup({ getProps, setProps, emit }) {
|
||||
const rootEl = h('div', {
|
||||
className: 'segmented',
|
||||
role: 'group',
|
||||
'aria-label': getProps().ariaLabel || '分段切换器',
|
||||
});
|
||||
setup({ getProps, setProps, emit, onCleanup }) {
|
||||
const gliderEl = h('div', { className: 'seg-glider', 'aria-hidden': 'true' });
|
||||
const rootEl = h(
|
||||
'div',
|
||||
{
|
||||
className: 'segmented',
|
||||
role: 'group',
|
||||
'aria-label': getProps().ariaLabel || '分段切换器',
|
||||
},
|
||||
[gliderEl]
|
||||
);
|
||||
|
||||
const btnMap = new Map();
|
||||
let orderedBtns = [];
|
||||
let activeBtnEl = null;
|
||||
let observedBtnEl = null;
|
||||
let hasMeasuredVisible = false;
|
||||
let readyRafId = 0;
|
||||
|
||||
function cancelReadyRaf() {
|
||||
if (readyRafId && typeof window !== 'undefined' && typeof window.cancelAnimationFrame === 'function') {
|
||||
window.cancelAnimationFrame(readyRafId);
|
||||
}
|
||||
readyRafId = 0;
|
||||
}
|
||||
|
||||
function syncGliderGeometry() {
|
||||
if (!activeBtnEl) {
|
||||
cancelReadyRaf();
|
||||
hasMeasuredVisible = false;
|
||||
patchClasses(rootEl, { 'has-glider': false });
|
||||
patchClasses(gliderEl, { 'is-ready': false });
|
||||
return;
|
||||
}
|
||||
|
||||
const w = Number(activeBtnEl.offsetWidth || 0);
|
||||
const h = Number(activeBtnEl.offsetHeight || 0);
|
||||
if (!(w > 0 && h > 0)) {
|
||||
// Hidden parent tab or headless Mock DOM: keep .seg-btn.is-active fallback background
|
||||
// and snap cleanly on first real paint when tab becomes visible.
|
||||
cancelReadyRaf();
|
||||
hasMeasuredVisible = false;
|
||||
patchClasses(rootEl, { 'has-glider': false });
|
||||
patchClasses(gliderEl, { 'is-ready': false });
|
||||
return;
|
||||
}
|
||||
|
||||
const x = Number(activeBtnEl.offsetLeft || 0);
|
||||
const y = Number(activeBtnEl.offsetTop || 0);
|
||||
patchStyleVar(gliderEl, '--glider-x', `${x}px`);
|
||||
patchStyleVar(gliderEl, '--glider-y', `${y}px`);
|
||||
patchStyleVar(gliderEl, '--glider-w', `${w}px`);
|
||||
patchStyleVar(gliderEl, '--glider-h', `${h}px`);
|
||||
patchClasses(rootEl, { 'has-glider': true });
|
||||
|
||||
if (!hasMeasuredVisible) {
|
||||
hasMeasuredVisible = true;
|
||||
patchClasses(gliderEl, { 'is-ready': false });
|
||||
void gliderEl.offsetWidth;
|
||||
if (typeof window !== 'undefined' && typeof window.requestAnimationFrame === 'function') {
|
||||
cancelReadyRaf();
|
||||
readyRafId = window.requestAnimationFrame(() => {
|
||||
readyRafId = 0;
|
||||
if (hasMeasuredVisible) {
|
||||
patchClasses(gliderEl, { 'is-ready': true });
|
||||
}
|
||||
});
|
||||
} else {
|
||||
patchClasses(gliderEl, { 'is-ready': true });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let resizeObs = null;
|
||||
if (typeof ResizeObserver === 'function') {
|
||||
resizeObs = new ResizeObserver(() => {
|
||||
syncGliderGeometry();
|
||||
});
|
||||
resizeObs.observe(rootEl);
|
||||
}
|
||||
|
||||
function updateObservedActiveButton(nextActiveBtn) {
|
||||
if (!resizeObs || observedBtnEl === nextActiveBtn) return;
|
||||
if (observedBtnEl) {
|
||||
try {
|
||||
resizeObs.unobserve(observedBtnEl);
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
observedBtnEl = nextActiveBtn || null;
|
||||
if (observedBtnEl) {
|
||||
try {
|
||||
resizeObs.observe(observedBtnEl);
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function selectValue(nextVal) {
|
||||
if (getProps().modelValue !== nextVal) {
|
||||
setProps({ modelValue: nextVal });
|
||||
emit('update:modelValue', nextVal);
|
||||
}
|
||||
}
|
||||
|
||||
function syncSegments() {
|
||||
const { options = [], modelValue } = getProps();
|
||||
patchKeyedList(rootEl, options, {
|
||||
keyFn: (opt) => opt.value,
|
||||
sigFn: (opt) => `${opt.value}::${opt.label}::${opt.value === modelValue}`,
|
||||
createRow: (opt) => {
|
||||
const btn = h('button', {
|
||||
const { options = [], modelValue, ariaLabel } = getProps();
|
||||
if (ariaLabel) {
|
||||
patchAttr(rootEl, 'aria-label', ariaLabel);
|
||||
}
|
||||
|
||||
const validKeys = new Set(options.map((opt) => String(opt.value)));
|
||||
for (const [key, btn] of btnMap.entries()) {
|
||||
if (!validKeys.has(key)) {
|
||||
if (btn.parentNode === rootEl) {
|
||||
rootEl.removeChild(btn);
|
||||
}
|
||||
btnMap.delete(key);
|
||||
}
|
||||
}
|
||||
|
||||
orderedBtns = [];
|
||||
let nextActiveBtn = null;
|
||||
|
||||
for (let i = 0; i < options.length; i++) {
|
||||
const opt = options[i];
|
||||
const key = String(opt.value);
|
||||
let btn = btnMap.get(key);
|
||||
if (!btn) {
|
||||
btn = h('button', {
|
||||
type: 'button',
|
||||
className: 'seg-btn',
|
||||
onClick: (e) => {
|
||||
e.stopPropagation();
|
||||
if (getProps().modelValue !== opt.value) {
|
||||
setProps({ modelValue: opt.value });
|
||||
emit('update:modelValue', opt.value);
|
||||
selectValue(opt.value);
|
||||
},
|
||||
onKeydown: (e) => {
|
||||
if (e.key === 'ArrowRight' || e.key === 'ArrowLeft') {
|
||||
e.preventDefault();
|
||||
const curOpts = getProps().options || [];
|
||||
if (!curOpts.length) return;
|
||||
const curIdx = Math.max(
|
||||
0,
|
||||
curOpts.findIndex((o) => String(o.value) === key)
|
||||
);
|
||||
const delta = e.key === 'ArrowRight' ? 1 : -1;
|
||||
const nextIdx = (curIdx + delta + curOpts.length) % curOpts.length;
|
||||
const targetOpt = curOpts[nextIdx];
|
||||
if (targetOpt) {
|
||||
selectValue(targetOpt.value);
|
||||
btnMap.get(String(targetOpt.value))?.focus?.();
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
return { el: btn, refs: {} };
|
||||
},
|
||||
updateRow: (_refs, opt, _idx, el) => {
|
||||
const active = opt.value === modelValue;
|
||||
patchText(el, opt.label);
|
||||
patchClasses(el, { 'is-active': active });
|
||||
patchAttr(el, 'aria-pressed', active ? 'true' : 'false');
|
||||
patchAttr(el, 'data-seg-value', opt.value);
|
||||
},
|
||||
});
|
||||
btnMap.set(key, btn);
|
||||
}
|
||||
|
||||
const active = opt.value === modelValue;
|
||||
patchText(btn, opt.label);
|
||||
patchClasses(btn, { 'is-active': active });
|
||||
patchAttr(btn, 'aria-pressed', active ? 'true' : 'false');
|
||||
patchAttr(btn, 'data-seg-value', opt.value);
|
||||
orderedBtns.push(btn);
|
||||
if (active) {
|
||||
nextActiveBtn = btn;
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure gliderEl remains index 0 and buttons follow in exact option order
|
||||
if (rootEl.firstChild !== gliderEl) {
|
||||
rootEl.insertBefore(gliderEl, rootEl.firstChild);
|
||||
}
|
||||
for (let i = 0; i < orderedBtns.length; i++) {
|
||||
const targetNode = orderedBtns[i];
|
||||
const currentAtSlot = rootEl.children[i + 1] || null;
|
||||
if (currentAtSlot !== targetNode) {
|
||||
rootEl.insertBefore(targetNode, currentAtSlot);
|
||||
}
|
||||
}
|
||||
|
||||
activeBtnEl = nextActiveBtn || orderedBtns[0] || null;
|
||||
updateObservedActiveButton(activeBtnEl);
|
||||
syncGliderGeometry();
|
||||
}
|
||||
|
||||
syncSegments();
|
||||
|
||||
onCleanup(() => {
|
||||
cancelReadyRaf();
|
||||
resizeObs?.disconnect?.();
|
||||
resizeObs = null;
|
||||
observedBtnEl = null;
|
||||
});
|
||||
|
||||
return {
|
||||
el: rootEl,
|
||||
refs: {},
|
||||
refs: { gliderEl, refreshGlider: syncGliderGeometry },
|
||||
onPropsChange: syncSegments,
|
||||
getValue: () => getProps().modelValue,
|
||||
};
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
import { defineComponent } from '../../core/component.js';
|
||||
import { isModernUiActiveForElement } from '../../core/appearance.js';
|
||||
import {
|
||||
h,
|
||||
patchAttr,
|
||||
@@ -30,8 +31,8 @@ const CTX_ASCII_CHAR_PX = 6.1;
|
||||
const CTX_PILL_GAP_PX = 4;
|
||||
const CTX_DEFAULT_BAR_WIDTH_PX = 310;
|
||||
|
||||
function estimateCtxPillWidth(text) {
|
||||
let w = CTX_PILL_BASE_PAD_PX;
|
||||
function estimateCtxPillWidth(text, withChevron = false) {
|
||||
let w = CTX_PILL_BASE_PAD_PX + (withChevron ? 14 : 0);
|
||||
for (const ch of String(text || '')) {
|
||||
w += ch.charCodeAt(0) > 255 ? CTX_CJK_CHAR_PX : CTX_ASCII_CHAR_PX;
|
||||
}
|
||||
@@ -244,9 +245,30 @@ export const ContextWindowWidget = defineComponent({
|
||||
|
||||
let latestData = null;
|
||||
let ctxPillsExpanded = false;
|
||||
let isCollapsingCtxPills = false;
|
||||
let ctxCollapseTimer = null;
|
||||
let lastCascadeId = '';
|
||||
let cachedBarWidth = 0;
|
||||
|
||||
function clearCtxExpandAnim() {
|
||||
if (ctxCollapseTimer) {
|
||||
clearTimeout(ctxCollapseTimer);
|
||||
ctxCollapseTimer = null;
|
||||
}
|
||||
isCollapsingCtxPills = false;
|
||||
ctxInspectorBar.ontransitionend = null;
|
||||
ctxInspectorBar.style.height = '';
|
||||
ctxInspectorBar.style.overflow = '';
|
||||
ctxInspectorBar.style.transition = '';
|
||||
for (const child of ctxPillGroup.children) {
|
||||
child.onanimationend = null;
|
||||
patchClasses(child, {
|
||||
'is-pill-entering': false,
|
||||
'is-pill-collapsing': false,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function update({ data } = {}) {
|
||||
latestData = data || null;
|
||||
const curLocale = getEffectiveLocale();
|
||||
@@ -277,6 +299,7 @@ export const ContextWindowWidget = defineComponent({
|
||||
const currentCascadeId = data.activeConversation?.cascadeId || '';
|
||||
if (currentCascadeId && currentCascadeId !== lastCascadeId) {
|
||||
if (lastCascadeId) {
|
||||
clearCtxExpandAnim();
|
||||
ctxPillsExpanded = false;
|
||||
}
|
||||
lastCascadeId = currentCascadeId;
|
||||
@@ -308,7 +331,10 @@ export const ContextWindowWidget = defineComponent({
|
||||
|
||||
if (interactiveInspector) {
|
||||
patchAttr(ctxInspectorBar, 'hidden', !hasSubagents);
|
||||
if (hasSubagents && ctxAgent) {
|
||||
if (!hasSubagents && isCollapsingCtxPills) {
|
||||
clearCtxExpandAnim();
|
||||
}
|
||||
if (hasSubagents && ctxAgent && !isCollapsingCtxPills) {
|
||||
const activeBadgeText = formatAgentBadgeText({
|
||||
agentKind:
|
||||
aggregated?.activeAgentKind ||
|
||||
@@ -355,7 +381,7 @@ export const ContextWindowWidget = defineComponent({
|
||||
|
||||
if (needsCollapse && !ctxPillsExpanded) {
|
||||
const toggleSample = t('ctx.expandMore', { count: allAgentPills.length });
|
||||
const toggleReservePx = CTX_PILL_GAP_PX + estimateCtxPillWidth(toggleSample);
|
||||
const toggleReservePx = CTX_PILL_GAP_PX + estimateCtxPillWidth(toggleSample, true);
|
||||
let usedW = firstPillWidth;
|
||||
let fitCount = 0;
|
||||
for (let i = 0; i < allAgentPills.length; i += 1) {
|
||||
@@ -386,6 +412,7 @@ export const ContextWindowWidget = defineComponent({
|
||||
title: t('ctx.expandMoreTitle', { count: allAgentPills.length - 1 }),
|
||||
isActive: false,
|
||||
isMoreToggle: true,
|
||||
isExpanded: false,
|
||||
mode: 'toggle-expand',
|
||||
});
|
||||
} else {
|
||||
@@ -397,6 +424,7 @@ export const ContextWindowWidget = defineComponent({
|
||||
title: t('ctx.collapseTitle'),
|
||||
isActive: false,
|
||||
isMoreToggle: true,
|
||||
isExpanded: true,
|
||||
mode: 'toggle-expand',
|
||||
});
|
||||
}
|
||||
@@ -405,22 +433,117 @@ export const ContextWindowWidget = defineComponent({
|
||||
patchKeyedList(ctxPillGroup, pillItems, {
|
||||
keyFn: (item) => item.key,
|
||||
sigFn: (item) =>
|
||||
`${item.key}:${item.label}:${item.isActive}:${item.isMoreToggle}:${item.mode}:${item.title}`,
|
||||
`${item.key}:${item.label}:${item.isActive}:${item.isMoreToggle}:${Boolean(item.isExpanded)}:${item.mode}:${item.title}`,
|
||||
createRow: () => {
|
||||
const btn = h('button', { type: 'button', className: 'ctx-agent-pill' });
|
||||
return { el: btn, refs: { btn } };
|
||||
const labelSpan = h('span', { className: 'ctx-pill-label' });
|
||||
const chevronEl = createSvgIcon('chevron-down', {
|
||||
size: 11,
|
||||
className: 'ctx-toggle-chevron',
|
||||
});
|
||||
patchAttr(chevronEl, 'hidden', true);
|
||||
const btn = h('button', { type: 'button', className: 'ctx-agent-pill' }, [
|
||||
labelSpan,
|
||||
chevronEl,
|
||||
]);
|
||||
return { el: btn, refs: { btn, labelSpan, chevronEl } };
|
||||
},
|
||||
updateRow: (refs, item) => {
|
||||
patchText(refs.btn, item.label);
|
||||
patchText(refs.labelSpan, item.label);
|
||||
patchAttr(refs.chevronEl, 'hidden', !item.isMoreToggle);
|
||||
patchAttr(refs.btn, 'title', item.title);
|
||||
patchAttr(refs.btn, 'data-pill-key', item.key);
|
||||
patchClasses(refs.btn, {
|
||||
'is-active': item.isActive,
|
||||
'is-more-toggle': Boolean(item.isMoreToggle),
|
||||
'is-expanded': Boolean(item.isExpanded),
|
||||
'is-pill-collapsing': false,
|
||||
});
|
||||
refs.btn.onclick = () => {
|
||||
if (item.mode === 'toggle-expand') {
|
||||
ctxPillsExpanded = !ctxPillsExpanded;
|
||||
if (latestData) update({ data: latestData });
|
||||
const modern = isModernUiActiveForElement(ctxPanel);
|
||||
const startH = Number(ctxInspectorBar.offsetHeight || 0);
|
||||
clearCtxExpandAnim();
|
||||
if (!modern || !(startH > 0)) {
|
||||
ctxPillsExpanded = !ctxPillsExpanded;
|
||||
if (latestData) update({ data: latestData });
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ctxPillsExpanded) {
|
||||
const prevKeys = new Set(
|
||||
Array.from(ctxPillGroup.children, (el) => el.getAttribute?.('data-pill-key') || '')
|
||||
);
|
||||
ctxPillsExpanded = true;
|
||||
if (latestData) update({ data: latestData });
|
||||
const endH = Number(ctxPillGroup.offsetHeight || 0);
|
||||
for (const child of ctxPillGroup.children) {
|
||||
const k = child.getAttribute?.('data-pill-key') || '';
|
||||
if (k && k !== '__toggle_more__' && !prevKeys.has(k)) {
|
||||
patchClasses(child, { 'is-pill-entering': true });
|
||||
child.onanimationend = () => {
|
||||
child.onanimationend = null;
|
||||
patchClasses(child, { 'is-pill-entering': false });
|
||||
};
|
||||
}
|
||||
}
|
||||
if (endH > startH + 1) {
|
||||
ctxInspectorBar.style.height = `${startH}px`;
|
||||
ctxInspectorBar.style.overflow = 'hidden';
|
||||
void ctxInspectorBar.offsetHeight;
|
||||
ctxInspectorBar.style.transition =
|
||||
'height 220ms cubic-bezier(0.16, 1, 0.3, 1)';
|
||||
ctxInspectorBar.style.height = `${endH}px`;
|
||||
const finishExpand = () => clearCtxExpandAnim();
|
||||
ctxInspectorBar.ontransitionend = (ev) => {
|
||||
if (
|
||||
ev?.target === ctxInspectorBar &&
|
||||
(!ev.propertyName || ev.propertyName === 'height')
|
||||
) {
|
||||
finishExpand();
|
||||
}
|
||||
};
|
||||
ctxCollapseTimer = setTimeout(finishExpand, 260);
|
||||
}
|
||||
} else {
|
||||
const firstPill = ctxPillGroup.children[0] || null;
|
||||
const firstTop = Number(firstPill?.offsetTop || 0);
|
||||
let firstRowH = Number(firstPill?.offsetHeight || 20);
|
||||
for (const child of ctxPillGroup.children) {
|
||||
const top = Number(child.offsetTop || 0);
|
||||
if (top <= firstTop + 4) {
|
||||
const bottom = top - firstTop + Number(child.offsetHeight || 0);
|
||||
if (bottom > firstRowH) firstRowH = bottom;
|
||||
}
|
||||
}
|
||||
const targetH = Math.max(18, firstRowH);
|
||||
ctxPillsExpanded = false;
|
||||
isCollapsingCtxPills = true;
|
||||
patchClasses(refs.btn, { 'is-expanded': false });
|
||||
for (const child of ctxPillGroup.children) {
|
||||
if (Number(child.offsetTop || 0) > firstTop + 4) {
|
||||
patchClasses(child, { 'is-pill-collapsing': true });
|
||||
}
|
||||
}
|
||||
ctxInspectorBar.style.height = `${startH}px`;
|
||||
ctxInspectorBar.style.overflow = 'hidden';
|
||||
void ctxInspectorBar.offsetHeight;
|
||||
ctxInspectorBar.style.transition =
|
||||
'height 200ms cubic-bezier(0.16, 1, 0.3, 1)';
|
||||
ctxInspectorBar.style.height = `${targetH}px`;
|
||||
const finishCollapse = () => {
|
||||
clearCtxExpandAnim();
|
||||
if (latestData) update({ data: latestData });
|
||||
};
|
||||
ctxInspectorBar.ontransitionend = (ev) => {
|
||||
if (
|
||||
ev?.target === ctxInspectorBar &&
|
||||
(!ev.propertyName || ev.propertyName === 'height')
|
||||
) {
|
||||
finishCollapse();
|
||||
}
|
||||
};
|
||||
ctxCollapseTimer = setTimeout(finishCollapse, 240);
|
||||
}
|
||||
} else {
|
||||
setCtxAgentId(item.key);
|
||||
}
|
||||
@@ -499,6 +622,7 @@ export const ContextWindowWidget = defineComponent({
|
||||
}
|
||||
|
||||
onCleanup(() => {
|
||||
clearCtxExpandAnim();
|
||||
if (ro) ro.disconnect();
|
||||
ctxSegmentBar.destroy();
|
||||
});
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
import { defineComponent } from '../../core/component.js';
|
||||
import { isModernUiActiveForElement } from '../../core/appearance.js';
|
||||
import {
|
||||
h,
|
||||
patchAttr,
|
||||
@@ -29,6 +30,7 @@ import {
|
||||
telemetryStore,
|
||||
} from '../../store/telemetryStore.js';
|
||||
import { uiStore } from '../../store/uiStore.js';
|
||||
import { CustomScrollbar } from '../ui/CustomScrollbar.js';
|
||||
|
||||
export function buildFallbackRunningConversations(
|
||||
data,
|
||||
@@ -197,6 +199,38 @@ export const LiveActivityWidget = defineComponent({
|
||||
}
|
||||
}
|
||||
|
||||
function readComputedPx(el, prop, fallback) {
|
||||
if (!el || typeof window === 'undefined' || typeof window.getComputedStyle !== 'function') {
|
||||
return fallback;
|
||||
}
|
||||
try {
|
||||
const val = parseFloat(window.getComputedStyle(el)?.[prop]);
|
||||
return Number.isFinite(val) ? val : fallback;
|
||||
} catch {
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
|
||||
function clearSubExpandAnim(refs) {
|
||||
if (!refs) return;
|
||||
if (refs.subAnimTimer) {
|
||||
clearTimeout(refs.subAnimTimer);
|
||||
refs.subAnimTimer = null;
|
||||
}
|
||||
refs.isCollapsingSubs = false;
|
||||
const host = refs.subScroll?.el;
|
||||
if (host) {
|
||||
host.ontransitionend = null;
|
||||
patchClasses(host, { 'is-sub-animating': false });
|
||||
host.style.height = '';
|
||||
host.style.paddingTop = '';
|
||||
host.style.marginTop = '';
|
||||
host.style.opacity = '';
|
||||
host.style.overflow = '';
|
||||
host.style.transition = '';
|
||||
}
|
||||
}
|
||||
|
||||
function createLiveTaskCard() {
|
||||
const dotIcon = createSvgIcon('dot', { size: 11 });
|
||||
patchClasses(dotIcon, { 'is-pulsing': true });
|
||||
@@ -219,12 +253,23 @@ export const LiveActivityWidget = defineComponent({
|
||||
text: '',
|
||||
})
|
||||
: null;
|
||||
const subToggleBtn = h('button', {
|
||||
type: 'button',
|
||||
className: 'live-sub-toggle',
|
||||
hidden: true,
|
||||
text: t('live.subToggleIdle', { total: 0, arrow: '▸' }),
|
||||
const subToggleLabel = h('span', {
|
||||
className: 'live-sub-toggle-label',
|
||||
text: t('live.subToggleIdle', { total: 0 }),
|
||||
});
|
||||
const subToggleChevron = createSvgIcon('chevron-down', {
|
||||
size: 11,
|
||||
className: 'live-sub-toggle-chevron',
|
||||
});
|
||||
const subToggleBtn = h(
|
||||
'button',
|
||||
{
|
||||
type: 'button',
|
||||
className: 'live-sub-toggle',
|
||||
hidden: true,
|
||||
},
|
||||
[subToggleLabel, subToggleChevron]
|
||||
);
|
||||
const elapsedEl = h('span', {
|
||||
className: 'live-activity-elapsed text-mono',
|
||||
text: '0s',
|
||||
@@ -273,7 +318,16 @@ export const LiveActivityWidget = defineComponent({
|
||||
]);
|
||||
|
||||
const subListEl = h('div', { className: 'live-sub-list', hidden: true });
|
||||
const cardEl = h('div', { className: 'live-task-card' }, [headerEl, mainRowEl, subListEl]);
|
||||
const subScroll = CustomScrollbar({
|
||||
contentEl: subListEl,
|
||||
className: 'live-sub-scroll-host',
|
||||
});
|
||||
patchAttr(subScroll.el, 'hidden', true);
|
||||
const cardEl = h('div', { className: 'live-task-card' }, [
|
||||
headerEl,
|
||||
mainRowEl,
|
||||
subScroll.el,
|
||||
]);
|
||||
|
||||
return {
|
||||
el: cardEl,
|
||||
@@ -284,6 +338,8 @@ export const LiveActivityWidget = defineComponent({
|
||||
hereTagEl,
|
||||
metricsEl,
|
||||
subToggleBtn,
|
||||
subToggleLabel,
|
||||
subToggleChevron,
|
||||
elapsedEl,
|
||||
mainBadge,
|
||||
mainPhase,
|
||||
@@ -291,6 +347,9 @@ export const LiveActivityWidget = defineComponent({
|
||||
mainSep,
|
||||
mainDetail,
|
||||
subListEl,
|
||||
subScroll,
|
||||
subAnimTimer: null,
|
||||
isCollapsingSubs: false,
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -352,7 +411,12 @@ export const LiveActivityWidget = defineComponent({
|
||||
patchAttr(liveActivityBar, 'hidden', !hasRunningTasks);
|
||||
if (!hasRunningTasks) {
|
||||
stopLiveTicker();
|
||||
patchKeyedList(liveActivityBar, [], {});
|
||||
patchKeyedList(liveActivityBar, [], {
|
||||
destroyRow: (refs) => {
|
||||
clearSubExpandAnim(refs);
|
||||
refs?.subScroll?.destroy?.();
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -479,19 +543,16 @@ export const LiveActivityWidget = defineComponent({
|
||||
patchAttr(refs.mainBadge, 'hidden', subCount === 0);
|
||||
patchAttr(refs.subToggleBtn, 'hidden', subCount === 0);
|
||||
if (subCount > 0) {
|
||||
const arrow = isExpanded ? '▾' : '▸';
|
||||
const toggleText =
|
||||
runSubCount > 0
|
||||
? t(isPureSwarm ? 'live.swarmToggleRunning' : 'live.subToggleRunning', {
|
||||
run: runSubCount,
|
||||
total: subCount,
|
||||
arrow,
|
||||
})
|
||||
: t(isPureSwarm ? 'live.swarmToggleIdle' : 'live.subToggleIdle', {
|
||||
total: subCount,
|
||||
arrow,
|
||||
});
|
||||
patchText(refs.subToggleBtn, toggleText);
|
||||
patchText(refs.subToggleLabel, toggleText);
|
||||
patchClasses(refs.subToggleBtn, { 'is-expanded': isExpanded });
|
||||
if (interactive) {
|
||||
patchAttr(
|
||||
@@ -501,11 +562,108 @@ export const LiveActivityWidget = defineComponent({
|
||||
);
|
||||
refs.subToggleBtn.onclick = (e) => {
|
||||
e.stopPropagation();
|
||||
manualSubExpandMap.set(item.cascadeId, !isExpanded);
|
||||
if (latestUpdateArgs) update(latestUpdateArgs);
|
||||
onLayoutChange?.();
|
||||
const nextExpanded = !resolveIsExpanded(item);
|
||||
const host = refs.subScroll.el;
|
||||
const curH = Number(host.offsetHeight || 0);
|
||||
const curPadTop = readComputedPx(host, 'paddingTop', 6);
|
||||
const curMarginTop = readComputedPx(host, 'marginTop', 3);
|
||||
const curOpacity = readComputedPx(host, 'opacity', 1);
|
||||
const parentGap = readComputedPx(refs.cardEl, 'rowGap', 7);
|
||||
const collapsedMarginTop = -Math.max(0, Math.round(parentGap));
|
||||
const wasMidAnim = Boolean(refs.subAnimTimer);
|
||||
clearSubExpandAnim(refs);
|
||||
manualSubExpandMap.set(item.cascadeId, nextExpanded);
|
||||
|
||||
const modern = isModernUiActiveForElement(refs.cardEl);
|
||||
if (!modern) {
|
||||
if (latestUpdateArgs) update(latestUpdateArgs);
|
||||
onLayoutChange?.();
|
||||
return;
|
||||
}
|
||||
|
||||
if (nextExpanded) {
|
||||
if (latestUpdateArgs) update(latestUpdateArgs);
|
||||
const endH = Number(host.offsetHeight || host.scrollHeight || 0);
|
||||
const endPadTop = readComputedPx(host, 'paddingTop', 6);
|
||||
const endMarginTop = readComputedPx(host, 'marginTop', 3);
|
||||
const fromH = wasMidAnim && curH > 0 ? curH : 0;
|
||||
const fromPadTop = wasMidAnim && curH > 0 ? curPadTop : 0;
|
||||
const fromMarginTop = wasMidAnim && curH > 0 ? curMarginTop : collapsedMarginTop;
|
||||
const fromOpacity = wasMidAnim && curH > 0 ? curOpacity : 0;
|
||||
if (endH > 0) {
|
||||
patchClasses(host, { 'is-sub-animating': true });
|
||||
host.style.height = `${fromH}px`;
|
||||
host.style.paddingTop = `${fromPadTop}px`;
|
||||
host.style.marginTop = `${fromMarginTop}px`;
|
||||
host.style.opacity = `${fromOpacity}`;
|
||||
host.style.overflow = 'hidden';
|
||||
void host.offsetHeight;
|
||||
host.style.transition =
|
||||
'height 220ms cubic-bezier(0.16, 1, 0.3, 1), padding-top 220ms cubic-bezier(0.16, 1, 0.3, 1), margin-top 220ms cubic-bezier(0.16, 1, 0.3, 1), opacity 180ms ease-out';
|
||||
host.style.height = `${endH}px`;
|
||||
host.style.paddingTop = `${endPadTop}px`;
|
||||
host.style.marginTop = `${endMarginTop}px`;
|
||||
host.style.opacity = '1';
|
||||
const finishExpand = () => {
|
||||
clearSubExpandAnim(refs);
|
||||
refs.subScroll.refresh();
|
||||
onLayoutChange?.();
|
||||
};
|
||||
host.ontransitionend = (ev) => {
|
||||
if (
|
||||
ev?.target === host &&
|
||||
(!ev.propertyName || ev.propertyName === 'height')
|
||||
) {
|
||||
finishExpand();
|
||||
}
|
||||
};
|
||||
refs.subAnimTimer = setTimeout(finishExpand, 260);
|
||||
} else {
|
||||
onLayoutChange?.();
|
||||
}
|
||||
} else {
|
||||
patchClasses(refs.subToggleBtn, { 'is-expanded': false });
|
||||
patchAttr(refs.subToggleBtn, 'title', t('live.subExpandTitle'));
|
||||
if (curH > 0) {
|
||||
refs.isCollapsingSubs = true;
|
||||
patchClasses(host, { 'is-sub-animating': true });
|
||||
host.style.height = `${curH}px`;
|
||||
host.style.paddingTop = `${curPadTop}px`;
|
||||
host.style.marginTop = `${curMarginTop}px`;
|
||||
host.style.opacity = `${curOpacity}`;
|
||||
host.style.overflow = 'hidden';
|
||||
void host.offsetHeight;
|
||||
host.style.transition =
|
||||
'height 200ms cubic-bezier(0.16, 1, 0.3, 1), padding-top 200ms cubic-bezier(0.16, 1, 0.3, 1), margin-top 200ms cubic-bezier(0.16, 1, 0.3, 1), opacity 150ms ease-out';
|
||||
host.style.height = '0px';
|
||||
host.style.paddingTop = '0px';
|
||||
host.style.marginTop = `${collapsedMarginTop}px`;
|
||||
host.style.opacity = '0';
|
||||
const finishCollapse = () => {
|
||||
clearSubExpandAnim(refs);
|
||||
patchAttr(host, 'hidden', true);
|
||||
patchAttr(refs.subListEl, 'hidden', true);
|
||||
if (latestUpdateArgs) update(latestUpdateArgs);
|
||||
onLayoutChange?.();
|
||||
};
|
||||
host.ontransitionend = (ev) => {
|
||||
if (
|
||||
ev?.target === host &&
|
||||
(!ev.propertyName || ev.propertyName === 'height')
|
||||
) {
|
||||
finishCollapse();
|
||||
}
|
||||
};
|
||||
refs.subAnimTimer = setTimeout(finishCollapse, 240);
|
||||
} else {
|
||||
if (latestUpdateArgs) update(latestUpdateArgs);
|
||||
onLayoutChange?.();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
} else if (refs.isCollapsingSubs) {
|
||||
clearSubExpandAnim(refs);
|
||||
}
|
||||
|
||||
const mainLabel = formatLiveActivityLabel(act, 'live.thinking');
|
||||
@@ -536,7 +694,10 @@ export const LiveActivityWidget = defineComponent({
|
||||
}
|
||||
|
||||
const showSubs = subCount > 0 && isExpanded;
|
||||
patchAttr(refs.subListEl, 'hidden', !showSubs);
|
||||
if (!refs.isCollapsingSubs) {
|
||||
patchAttr(refs.subScroll.el, 'hidden', !showSubs);
|
||||
patchAttr(refs.subListEl, 'hidden', !showSubs);
|
||||
}
|
||||
if (showSubs) {
|
||||
const rawSubItems = item.subagents || [];
|
||||
const getSubSortRank = (s) => {
|
||||
@@ -651,8 +812,13 @@ export const LiveActivityWidget = defineComponent({
|
||||
}
|
||||
},
|
||||
});
|
||||
refs.subScroll.refresh();
|
||||
}
|
||||
},
|
||||
destroyRow: (refs) => {
|
||||
clearSubExpandAnim(refs);
|
||||
refs?.subScroll?.destroy?.();
|
||||
},
|
||||
});
|
||||
|
||||
for (const key of [...activityTimersMap.keys()]) {
|
||||
@@ -666,6 +832,12 @@ export const LiveActivityWidget = defineComponent({
|
||||
|
||||
onCleanup(() => {
|
||||
stopLiveTicker();
|
||||
patchKeyedList(liveActivityBar, [], {
|
||||
destroyRow: (refs) => {
|
||||
clearSubExpandAnim(refs);
|
||||
refs?.subScroll?.destroy?.();
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
return {
|
||||
|
||||
@@ -131,6 +131,43 @@ export const StepTableWidget = defineComponent({
|
||||
const hoverRows = new WeakMap();
|
||||
let lastRenderedRows = null;
|
||||
let lastRenderOptions = '';
|
||||
let trackedCascadeId = null;
|
||||
const seenStepKeys = new Set();
|
||||
const maxSeenStepByAgent = new Map();
|
||||
const activeEnterTimers = new Map();
|
||||
|
||||
function getStepRowIdentity(st, fallbackCascadeId) {
|
||||
const agentKey = String(st?.agentCascadeId || fallbackCascadeId || 'conv');
|
||||
const stepNum = Number(st?.stepIndex);
|
||||
const rowKey = `${agentKey}-${st?.stepIndex}`;
|
||||
return { agentKey, stepNum, rowKey };
|
||||
}
|
||||
|
||||
function absorbStepsIntoBaseline(stepList, fallbackCascadeId) {
|
||||
if (!Array.isArray(stepList)) return;
|
||||
for (const st of stepList) {
|
||||
if (!st || typeof st !== 'object') continue;
|
||||
const { agentKey, stepNum, rowKey } = getStepRowIdentity(st, fallbackCascadeId);
|
||||
seenStepKeys.add(rowKey);
|
||||
if (Number.isFinite(stepNum)) {
|
||||
const prevMax = maxSeenStepByAgent.get(agentKey);
|
||||
if (prevMax === undefined || stepNum > prevMax) {
|
||||
maxSeenStepByAgent.set(agentKey, stepNum);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function clearRowEnterState(tr) {
|
||||
if (!tr) return;
|
||||
const timer = activeEnterTimers.get(tr);
|
||||
if (timer) {
|
||||
clearTimeout(timer);
|
||||
activeEnterTimers.delete(tr);
|
||||
}
|
||||
tr.onanimationend = null;
|
||||
patchClasses(tr, { 'is-step-entering': false });
|
||||
}
|
||||
|
||||
function enterStepCell(event) {
|
||||
const { badge, prompt } = hoverRows.get(this);
|
||||
@@ -171,8 +208,37 @@ export const StepTableWidget = defineComponent({
|
||||
showStepSpeedColor = false,
|
||||
stepTokenComboFormat = undefined,
|
||||
displaySettings = {},
|
||||
allConversationSteps = null,
|
||||
allowNewRowFade = false,
|
||||
} = {}
|
||||
) {
|
||||
const normCascadeId = String(cascadeId || '');
|
||||
let enteringRowKeys = null;
|
||||
if (!normCascadeId || trackedCascadeId === null || normCascadeId !== trackedCascadeId) {
|
||||
trackedCascadeId = normCascadeId || null;
|
||||
seenStepKeys.clear();
|
||||
maxSeenStepByAgent.clear();
|
||||
absorbStepsIntoBaseline(allConversationSteps, normCascadeId);
|
||||
absorbStepsIntoBaseline(tableSteps, normCascadeId);
|
||||
} else if (!allowNewRowFade || standalone) {
|
||||
absorbStepsIntoBaseline(allConversationSteps, normCascadeId);
|
||||
absorbStepsIntoBaseline(tableSteps, normCascadeId);
|
||||
} else {
|
||||
for (const st of tableSteps) {
|
||||
if (!st || typeof st !== 'object') continue;
|
||||
const { agentKey, stepNum, rowKey } = getStepRowIdentity(st, normCascadeId);
|
||||
if (!seenStepKeys.has(rowKey)) {
|
||||
const prevMax = maxSeenStepByAgent.get(agentKey);
|
||||
if (prevMax === undefined || !Number.isFinite(stepNum) || stepNum > prevMax) {
|
||||
enteringRowKeys ??= new Set();
|
||||
enteringRowKeys.add(rowKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
absorbStepsIntoBaseline(allConversationSteps, normCascadeId);
|
||||
absorbStepsIntoBaseline(tableSteps, normCascadeId);
|
||||
}
|
||||
|
||||
const colOrderSig = colKeys.join(',');
|
||||
const normTokenFmt = normalizeClientStepTokenComboFormat(stepTokenComboFormat);
|
||||
const renderOptions = JSON.stringify([
|
||||
@@ -424,6 +490,21 @@ export const StepTableWidget = defineComponent({
|
||||
hoverTd.onmousemove = firstColKey === 'step' ? moveInStepCell : moveAlongTurnRail;
|
||||
hoverTd.onmouseleave = hideTurnTip;
|
||||
}
|
||||
|
||||
if (enteringRowKeys?.has(item.rowKey)) {
|
||||
clearRowEnterState(tr);
|
||||
patchClasses(tr, { 'is-step-entering': true });
|
||||
tr.onanimationend = (ev) => {
|
||||
if (!ev || !ev.target || ev.target === tr) {
|
||||
clearRowEnterState(tr);
|
||||
}
|
||||
};
|
||||
const timer = setTimeout(() => clearRowEnterState(tr), 960);
|
||||
activeEnterTimers.set(tr, timer);
|
||||
}
|
||||
},
|
||||
destroyRow: (_refs, tr) => {
|
||||
clearRowEnterState(tr);
|
||||
},
|
||||
});
|
||||
lastRenderOptions = renderOptions;
|
||||
@@ -433,6 +514,9 @@ export const StepTableWidget = defineComponent({
|
||||
onCleanup(() => {
|
||||
stepsTablePane.removeEventListener('scroll', hideTurnTip);
|
||||
stepsTbody.removeEventListener('mouseleave', hideTurnTip);
|
||||
for (const tr of [...activeEnterTimers.keys()]) {
|
||||
clearRowEnterState(tr);
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user