feat(panel): add experimental modern UI, sliding switchers, cycle range, and fluid animations

This commit is contained in:
fish
2026-11-19 15:05:27 +09:00
parent 70629dcd74
commit 367ca0cd6d
35 changed files with 5066 additions and 294 deletions
@@ -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 {
+337 -10
View File
@@ -38,23 +38,342 @@ export function normalizeClientFontScale(raw) {
return Object.prototype.hasOwnProperty.call(FONT_SCALE_FACTORS, val) ? val : 'md';
}
export function normalizeClientModernUi(raw) {
if (typeof raw === 'string') {
const lower = raw.trim().toLowerCase();
return lower === 'true' || lower === '1' || lower === 'on';
}
return Boolean(raw);
}
/**
* Check whether `el` (or its Shadow DOM host / document root) is currently under `[data-modern-ui="true"]`.
*
* @param {Node | null | undefined} el
* @returns {boolean}
*/
export function isModernUiActiveForElement(el) {
let cur = el || null;
while (cur) {
if (typeof cur.getAttribute === 'function' && cur.getAttribute('data-modern-ui') === 'true') {
return true;
}
if (cur.parentNode) {
cur = cur.parentNode;
} else if (cur.host) {
cur = cur.host;
} else {
break;
}
}
if (typeof document !== 'undefined' && document.documentElement) {
return document.documentElement.getAttribute?.('data-modern-ui') === 'true';
}
return false;
}
const LIGHT_THEME_CLASSES = new Set([
'light',
'vs-light',
'vscode-light',
'hc-light',
'vscode-high-contrast-light',
]);
const DARK_THEME_CLASSES = new Set([
'dark',
'vs-dark',
'vscode-dark',
'hc-black',
'vscode-high-contrast',
]);
function hslToRgb(hDeg, sPct, lPct) {
const h = (((hDeg % 360) + 360) % 360) / 360;
const s = Math.max(0, Math.min(1, sPct / 100));
const l = Math.max(0, Math.min(1, lPct / 100));
if (s === 0) {
const v = l * 255;
return [v, v, v];
}
const hue2rgb = (p, q, t) => {
let tt = t;
if (tt < 0) tt += 1;
if (tt > 1) tt -= 1;
if (tt < 1 / 6) return p + (q - p) * 6 * tt;
if (tt < 1 / 2) return q;
if (tt < 2 / 3) return p + (q - p) * (2 / 3 - tt) * 6;
return p;
};
const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
const p = 2 * l - q;
return [
hue2rgb(p, q, h + 1 / 3) * 255,
hue2rgb(p, q, h) * 255,
hue2rgb(p, q, h - 1 / 3) * 255,
];
}
function parseAlphaToken(rawAlpha) {
if (rawAlpha == null || rawAlpha === '') return 1;
const str = String(rawAlpha).trim();
if (!str) return 1;
if (str.endsWith('%')) {
const pct = parseFloat(str);
return Number.isFinite(pct) ? pct / 100 : 1;
}
const num = parseFloat(str);
return Number.isFinite(num) ? num : 1;
}
/**
* Parse `#hex`, `rgb()/rgba()`, or `hsl()/hsla()` into perceptual luminance `[0, 1]`.
* Returns `null` when transparent (`alpha <= 0.15`) or unparseable.
*
* @param {string | null | undefined} rawColor
* @returns {number | null}
*/
export function parseCssColorLuminance(rawColor) {
const str = String(rawColor ?? '').trim().toLowerCase();
if (!str || str === 'transparent' || str === 'none' || str === 'inherit' || str === 'initial') {
return null;
}
if (str.startsWith('#')) {
const hex = str.slice(1);
let r = 0;
let g = 0;
let b = 0;
let a = 1;
if (hex.length === 3 || hex.length === 4) {
r = parseInt(hex[0] + hex[0], 16);
g = parseInt(hex[1] + hex[1], 16);
b = parseInt(hex[2] + hex[2], 16);
if (hex.length === 4) a = parseInt(hex[3] + hex[3], 16) / 255;
} else if (hex.length === 6 || hex.length === 8) {
r = parseInt(hex.slice(0, 2), 16);
g = parseInt(hex.slice(2, 4), 16);
b = parseInt(hex.slice(4, 6), 16);
if (hex.length === 8) a = parseInt(hex.slice(6, 8), 16) / 255;
} else {
return null;
}
if (!Number.isFinite(r) || !Number.isFinite(g) || !Number.isFinite(b) || a <= 0.15) {
return null;
}
return (0.299 * r + 0.587 * g + 0.114 * b) / 255;
}
const rgbMatch = str.match(/^rgba?\(([^)]+)\)$/);
if (rgbMatch) {
const body = rgbMatch[1].trim();
const [channelsPart, slashAlpha] = body.split('/');
const parts = channelsPart
.trim()
.split(/[\s,]+/)
.filter(Boolean);
if (parts.length < 3) return null;
const parseChan = (tok) =>
tok.endsWith('%') ? (parseFloat(tok) / 100) * 255 : parseFloat(tok);
const r = parseChan(parts[0]);
const g = parseChan(parts[1]);
const b = parseChan(parts[2]);
const a = slashAlpha !== undefined ? parseAlphaToken(slashAlpha) : parseAlphaToken(parts[3]);
if (!Number.isFinite(r) || !Number.isFinite(g) || !Number.isFinite(b) || a <= 0.15) {
return null;
}
return (0.299 * r + 0.587 * g + 0.114 * b) / 255;
}
const hslMatch = str.match(/^hsla?\(([^)]+)\)$/);
if (hslMatch) {
const body = hslMatch[1].trim();
const [channelsPart, slashAlpha] = body.split('/');
const parts = channelsPart
.trim()
.split(/[\s,]+/)
.filter(Boolean);
if (parts.length < 3) return null;
const h = parseFloat(parts[0]);
const s = parseFloat(parts[1]);
const l = parseFloat(parts[2]);
const a = slashAlpha !== undefined ? parseAlphaToken(slashAlpha) : parseAlphaToken(parts[3]);
if (!Number.isFinite(h) || !Number.isFinite(s) || !Number.isFinite(l) || a <= 0.15) {
return null;
}
const [r, g, b] = hslToRgb(h, s, l);
return (0.299 * r + 0.587 * g + 0.114 * b) / 255;
}
return null;
}
function readStyleProp(el, cs, prop) {
if (prop.startsWith('--')) {
const inlineVal =
typeof el?.style?.getPropertyValue === 'function'
? el.style.getPropertyValue(prop)
: el?.style?.[prop];
if (inlineVal && String(inlineVal).trim()) return String(inlineVal).trim();
const compVal = cs?.getPropertyValue?.(prop);
return compVal ? String(compVal).trim() : '';
}
const inlineVal = el?.style?.[prop];
if (inlineVal && String(inlineVal).trim()) return String(inlineVal).trim();
const compVal = cs?.[prop];
return compVal ? String(compVal).trim() : '';
}
/**
* Detect whether the active host surface is `'light'` or `'dark'`.
* Inspects explicit Antigravity / VS Code theme classes & attributes first,
* then actual computed surface/text luminance, then `prefers-color-scheme`.
*
* @param {HTMLElement | null | undefined} [targetEl]
* @returns {'light' | 'dark'}
*/
export function detectHostColorScheme(targetEl = null) {
const doc = typeof document !== 'undefined' ? document : null;
const win = typeof window !== 'undefined' ? window : null;
let workbenchEl = null;
try {
workbenchEl =
typeof doc?.querySelector === 'function' ? doc.querySelector('.monaco-workbench') : null;
} catch {
workbenchEl = null;
}
const candidates = [];
for (const el of [doc?.body, doc?.documentElement, workbenchEl, targetEl]) {
if (el && !candidates.includes(el)) {
candidates.push(el);
}
}
// 1. Explicit host theme attributes & class tokens (never read our own data-color-scheme)
for (const el of candidates) {
const vscodeKind = String(el.getAttribute?.('data-vscode-theme-kind') || '')
.trim()
.toLowerCase();
if (vscodeKind) {
if (vscodeKind.includes('light')) return 'light';
if (vscodeKind.includes('dark') || vscodeKind.includes('high-contrast')) return 'dark';
}
const dataTheme = String(
el.getAttribute?.('data-theme') || el.getAttribute?.('data-color-mode') || ''
)
.trim()
.toLowerCase();
if (dataTheme === 'light' || dataTheme.endsWith('-light')) return 'light';
if (dataTheme === 'dark' || dataTheme.endsWith('-dark')) return 'dark';
const rawCls = typeof el.className === 'string' ? el.className : '';
if (rawCls) {
const tokens = rawCls.trim().toLowerCase().split(/\s+/);
for (const tok of tokens) {
if (LIGHT_THEME_CLASSES.has(tok)) return 'light';
if (DARK_THEME_CLASSES.has(tok)) return 'dark';
}
}
}
// 2. Computed / inline surface background luminance
const bgTargets = [];
for (const el of [targetEl, doc?.body, doc?.documentElement, workbenchEl]) {
if (el && !bgTargets.includes(el)) {
bgTargets.push(el);
}
}
const bgProps = [
'--background',
'--card',
'--vscode-sideBar-background',
'--vscode-editor-background',
'backgroundColor',
];
for (const el of bgTargets) {
let cs = null;
try {
cs = typeof win?.getComputedStyle === 'function' ? win.getComputedStyle(el) : null;
} catch {
cs = null;
}
for (const prop of bgProps) {
const lum = parseCssColorLuminance(readStyleProp(el, cs, prop));
if (lum !== null) {
return lum > 0.52 ? 'light' : 'dark';
}
}
}
// 3. Computed / inline foreground text luminance
const fgProps = ['--foreground', '--vscode-foreground', '--vscode-editor-foreground', 'color'];
for (const el of bgTargets) {
let cs = null;
try {
cs = typeof win?.getComputedStyle === 'function' ? win.getComputedStyle(el) : null;
} catch {
cs = null;
}
for (const prop of fgProps) {
const lum = parseCssColorLuminance(readStyleProp(el, cs, prop));
if (lum !== null) {
return lum < 0.48 ? 'light' : 'dark';
}
}
}
// 4. OS media query fallback
try {
if (win?.matchMedia?.('(prefers-color-scheme: dark)')?.matches) {
return 'dark';
}
} catch {
// ignore matchMedia errors
}
return 'light';
}
function setAttrIfChanged(el, name, value) {
if (!el || typeof el.setAttribute !== 'function') return;
if (typeof el.getAttribute === 'function' && el.getAttribute(name) === value) return;
el.setAttribute(name, value);
}
function removeAttrIfPresent(el, name) {
if (!el || typeof el.removeAttribute !== 'function') return;
if (typeof el.hasAttribute === 'function' && !el.hasAttribute(name)) return;
el.removeAttribute(name);
}
function setOrClearStyleVar(el, propName, value) {
if (!el || !el.style) return;
const cur =
typeof el.style.getPropertyValue === 'function'
? el.style.getPropertyValue(propName)
: el.style[propName] || '';
if (value) {
if (cur === value) return;
if (typeof el.style.setProperty === 'function') {
el.style.setProperty(propName, value);
} else {
el.style[propName] = value;
}
} else if (typeof el.style.removeProperty === 'function') {
el.style.removeProperty(propName);
} else if (typeof el.style.setProperty === 'function') {
el.style.setProperty(propName, '');
} else if (cur) {
if (typeof el.style.removeProperty === 'function') {
el.style.removeProperty(propName);
} else if (typeof el.style.setProperty === 'function') {
el.style.setProperty(propName, '');
} else {
el.style[propName] = '';
}
}
}
/**
* Synchronize theme accent and (optionally) font scale tokens onto a root/host element.
* Synchronize theme accent, host color scheme polarity, and (optionally) font scale tokens
* onto a root/host element.
*
* @param {HTMLElement | null | undefined} targetEl
* @param {object | null | undefined} settings
@@ -72,7 +391,17 @@ export function applyAppearanceToRoot(targetEl, settings, { includeFontScale = t
setOrClearStyleVar(targetEl, '--user-accent-primary', '');
setOrClearStyleVar(targetEl, '--user-accent-contrast', '');
}
targetEl.setAttribute?.('data-accent', preset.key);
setAttrIfChanged(targetEl, 'data-accent', preset.key);
const colorScheme = detectHostColorScheme(targetEl);
setAttrIfChanged(targetEl, 'data-color-scheme', colorScheme);
const isModernUi = normalizeClientModernUi(settings?.experimentalModernUi);
if (isModernUi) {
setAttrIfChanged(targetEl, 'data-modern-ui', 'true');
} else {
removeAttrIfPresent(targetEl, 'data-modern-ui');
}
if (includeFontScale) {
const scaleKey = normalizeClientFontScale(settings?.fontScale);
@@ -80,12 +409,10 @@ export function applyAppearanceToRoot(targetEl, settings, { includeFontScale = t
const panelFactor = PANEL_SCALE_FACTORS[scaleKey] ?? 1;
setOrClearStyleVar(targetEl, '--ui-font-scale', factor === 1 ? '' : String(factor));
setOrClearStyleVar(targetEl, '--ui-panel-scale', panelFactor === 1 ? '' : String(panelFactor));
targetEl.setAttribute?.('data-font-scale', scaleKey);
setAttrIfChanged(targetEl, 'data-font-scale', scaleKey);
} else {
setOrClearStyleVar(targetEl, '--ui-font-scale', '');
setOrClearStyleVar(targetEl, '--ui-panel-scale', '');
if (typeof targetEl.removeAttribute === 'function') {
targetEl.removeAttribute('data-font-scale');
}
removeAttrIfPresent(targetEl, 'data-font-scale');
}
}
+6 -1
View File
@@ -131,7 +131,11 @@ const keyedListState = new WeakMap();
* Keyed incremental list reconciler.
* Reuses existing DOM nodes by key and patches only changed items in-place.
*/
export function patchKeyedList(container, items, { keyFn, sigFn, createRow, updateRow }) {
export function patchKeyedList(
container,
items,
{ keyFn = (_, i) => i, sigFn, createRow, updateRow, destroyRow } = {}
) {
if (!container) return;
let map = keyedListState.get(container);
if (!map) {
@@ -175,6 +179,7 @@ export function patchKeyedList(container, items, { keyFn, sigFn, createRow, upda
if (record.el.parentNode === container) {
container.removeChild(record.el);
}
destroyRow?.(record.refs, record.el);
map.delete(oldKey);
}
}
+11 -6
View File
@@ -145,9 +145,9 @@ export const I18N_MESSAGES_EN_US = Object.freeze({
// Context Window Widget
'ctx.followActive': 'Follow Active ({badge})',
'ctx.followActiveTitle': 'Automatically inspect the active or running agent context window',
'ctx.expandMore': '+{count} More ▾',
'ctx.expandMore': '+{count} More',
'ctx.expandMoreTitle': 'Expand all {count} subagent context pills',
'ctx.collapse': 'Less ▴',
'ctx.collapse': 'Less',
'ctx.collapseTitle': 'Collapse extra subagent pills',
'ctx.ch.assistant': 'Assistant',
'ctx.ch.assistantTitle': 'Model reasoning, responses, and tool call arguments',
@@ -199,14 +199,15 @@ export const I18N_MESSAGES_EN_US = Object.freeze({
'live.doneWithSteps': 'Done ({steps} steps)',
'live.waitingWithSteps': 'Waiting ({steps} steps)',
'live.killedWithSteps': 'Killed ({steps} steps)',
'live.subToggleRunning': 'Subagents {run}/{total} {arrow}',
'live.subToggleIdle': 'Subagents ({total}) {arrow}',
'live.swarmToggleRunning': 'Swarm {run}/{total} {arrow}',
'live.swarmToggleIdle': 'Swarm ({total}) {arrow}',
'live.subToggleRunning': 'Subagents {run}/{total}',
'live.subToggleIdle': 'Subagents ({total})',
'live.swarmToggleRunning': 'Swarm {run}/{total}',
'live.swarmToggleIdle': 'Swarm ({total})',
'live.subCollapseTitle': 'Collapse subagent list',
'live.subExpandTitle': 'Expand subagent activity list',
// Consumption View
'cons.rangeCycle': 'Cycle',
'cons.rangeToday': 'Today',
'cons.range24h': '24h',
'cons.range7d': '7d',
@@ -406,6 +407,10 @@ export const I18N_MESSAGES_EN_US = Object.freeze({
'settings.gen.fontLg': 'Large',
'settings.gen.fontXl': 'XL',
'settings.gen.fontHint': 'Scales sidebar and popover typography while keeping the inline capsule compact',
'settings.gen.modernUi': 'Modern UI (Experimental)',
'settings.gen.modernUiOff': 'Off',
'settings.gen.modernUiOn': 'On',
'settings.gen.modernUiHint': 'Removes most borders in favor of soft tonal surfaces and smoother animations',
'settings.gen.updateTitle': 'Updates & Pricing',
'settings.gen.updateMode': 'Update Policy',
'settings.gen.updateManual': 'Notify only, update manually',
+11 -6
View File
@@ -145,9 +145,9 @@ export const I18N_MESSAGES_ZH_CN = Object.freeze({
// Context Window Widget
'ctx.followActive': '跟随活跃 ({badge})',
'ctx.followActiveTitle': '自动展示当前正在运行或最新活跃的代理上下文窗口',
'ctx.expandMore': '+{count} 展开 ▾',
'ctx.expandMore': '+{count} 展开',
'ctx.expandMoreTitle': '展开全部 {count} 个子代理的上下文窗口胶囊',
'ctx.collapse': '收起 ▴',
'ctx.collapse': '收起',
'ctx.collapseTitle': '折叠多余子代理胶囊',
'ctx.ch.assistant': '模型回复',
'ctx.ch.assistantTitle': '模型推理思考、回复正文与工具调用入参',
@@ -199,14 +199,15 @@ export const I18N_MESSAGES_ZH_CN = Object.freeze({
'live.doneWithSteps': '已完成 ({steps} 步)',
'live.waitingWithSteps': '待命中 ({steps} 步)',
'live.killedWithSteps': '已终止 ({steps} 步)',
'live.subToggleRunning': '子代理 {run}/{total} {arrow}',
'live.subToggleIdle': '子代理 ({total}) {arrow}',
'live.swarmToggleRunning': '蜂群 {run}/{total} {arrow}',
'live.swarmToggleIdle': '蜂群 ({total}) {arrow}',
'live.subToggleRunning': '子代理 {run}/{total}',
'live.subToggleIdle': '子代理 ({total})',
'live.swarmToggleRunning': '蜂群 {run}/{total}',
'live.swarmToggleIdle': '蜂群 ({total})',
'live.subCollapseTitle': '点击收起子代理列表',
'live.subExpandTitle': '点击展开查看子代理缩略状态',
// Consumption View
'cons.rangeCycle': '周期',
'cons.rangeToday': '今天',
'cons.range24h': '1天',
'cons.range7d': '7天',
@@ -406,6 +407,10 @@ export const I18N_MESSAGES_ZH_CN = Object.freeze({
'settings.gen.fontLg': '大',
'settings.gen.fontXl': '特大',
'settings.gen.fontHint': '等比缩放侧边栏与展开面板字号,顶栏及输入框内嵌胶囊保持紧凑定高',
'settings.gen.modernUi': '新 UI(实验性)',
'settings.gen.modernUiOff': '关闭',
'settings.gen.modernUiOn': '开启',
'settings.gen.modernUiHint': '去除大部分线框,采用柔和分层底色与更流畅的现代过渡动画',
'settings.gen.updateTitle': '版本更新',
'settings.gen.updateMode': '更新方式',
'settings.gen.updateManual': '仅提示新版本,手动更新',
+38
View File
@@ -29,10 +29,48 @@ async function bootstrapApp(mountTarget = document.getElementById('app-root')) {
syncDocAppearance
);
let hostThemeObserver = null;
let colorSchemeMql = null;
const onHostThemeChange = () => {
syncDocAppearance(telemetryStore.getState().telemetry?.settings);
};
try {
if (typeof MutationObserver !== 'undefined' && typeof document !== 'undefined') {
hostThemeObserver = new MutationObserver(onHostThemeChange);
if (document.documentElement) {
hostThemeObserver.observe(document.documentElement, {
attributes: true,
attributeFilter: ['class', 'style', 'data-theme', 'data-vscode-theme-kind'],
});
}
if (document.body) {
hostThemeObserver.observe(document.body, {
attributes: true,
attributeFilter: ['class', 'style', 'data-theme', 'data-vscode-theme-kind'],
});
}
if (document.head) {
hostThemeObserver.observe(document.head, {
childList: true,
characterData: true,
subtree: true,
});
}
}
if (typeof window !== 'undefined' && typeof window.matchMedia === 'function') {
colorSchemeMql = window.matchMedia('(prefers-color-scheme: dark)');
colorSchemeMql?.addEventListener?.('change', onHostThemeChange);
}
} catch {
// ignore observer setup errors in constrained environments
}
const stopPolling = startAsyncTelemetryLoop(2000);
return {
appInstance,
stopPolling: () => {
hostThemeObserver?.disconnect?.();
colorSchemeMql?.removeEventListener?.('change', onHostThemeChange);
unsubAppearance();
stopPolling();
},
+9 -1
View File
@@ -14,7 +14,11 @@ import {
getAgentBadgeClass,
} from '../core/formatters.js';
import { normalizeI18nLanguage, t } from '../i18n/index.js';
import { normalizeClientFontScale, normalizeClientThemeAccent } from '../core/appearance.js';
import {
normalizeClientFontScale,
normalizeClientModernUi,
normalizeClientThemeAccent,
} from '../core/appearance.js';
import {
DEFAULT_HOVER_MODULES,
DEFAULT_OVERVIEW_METRICS,
@@ -195,6 +199,7 @@ export function isEquivalentTelemetry(prev, next) {
if ((pSet?.language ?? 'zh-CN') !== (nSet?.language ?? 'zh-CN')) return false;
if ((pSet?.themeAccent ?? 'host') !== (nSet?.themeAccent ?? 'host')) return false;
if ((pSet?.fontScale ?? 'md') !== (nSet?.fontScale ?? 'md')) return false;
if (Boolean(pSet?.experimentalModernUi) !== Boolean(nSet?.experimentalModernUi)) return false;
if ((prev.hostPlatform || '') !== (next.hostPlatform || '')) return false;
if (Boolean(pSet?.contextWindowRiskAccepted) !== Boolean(nSet?.contextWindowRiskAccepted)) {
return false;
@@ -895,6 +900,9 @@ export async function saveSettingsPatch(patch) {
if (Object.prototype.hasOwnProperty.call(safePatch, 'fontScale')) {
safePatch.fontScale = normalizeClientFontScale(safePatch.fontScale);
}
if (Object.prototype.hasOwnProperty.call(safePatch, 'experimentalModernUi')) {
safePatch.experimentalModernUi = normalizeClientModernUi(safePatch.experimentalModernUi);
}
if (Object.prototype.hasOwnProperty.call(safePatch, 'weeklyLimitMode')) {
safePatch.weeklyLimitMode = normalizeWeeklyLimitMode(safePatch.weeklyLimitMode);
}
+4
View File
@@ -54,6 +54,10 @@ td {
color: inherit;
}
button:focus:not(:focus-visible) {
outline: none;
}
input[type="number"] {
appearance: textfield;
-moz-appearance: textfield;
+60 -1
View File
@@ -95,6 +95,7 @@
color: var(--text-secondary);
border: 1px solid var(--border-hairline);
border-radius: var(--radius-xs);
outline: none;
cursor: pointer;
user-select: none;
transition:
@@ -104,6 +105,17 @@
transform var(--dur-instant) var(--ease-fast);
}
.icon-btn:focus-visible,
.pill-tab:focus-visible,
.select-trigger:focus-visible,
.seg-btn:focus-visible,
.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.btn-ghost-sm:focus-visible {
outline: none;
box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--accent-primary) 55%, transparent);
}
.icon-btn:hover {
background: var(--surface-hover);
color: var(--text-primary);
@@ -155,6 +167,7 @@
min-height: calc(26px * var(--ui-font-scale, 1));
padding: 2px var(--space-2);
border: none;
outline: none;
background: transparent;
color: var(--text-secondary);
font-size: var(--fs-base);
@@ -569,17 +582,51 @@
color: var(--text-primary);
}
/* --- 6. 微边框分段控制器 (Micro-Bezel Segmented Control) --- */
/* --- 6. 微边框分段控制器 (Micro-Bezel Sliding Segmented Control) --- */
.segmented {
position: relative;
display: inline-flex;
flex-wrap: wrap;
align-items: center;
align-self: flex-start;
width: fit-content;
gap: 2px;
max-width: 100%;
padding: 0;
background: transparent;
border: none;
user-select: none;
}
.seg-glider {
position: absolute;
top: 0;
left: 0;
width: var(--glider-w, 0px);
height: var(--glider-h, 0px);
border-radius: var(--radius-xs);
background: var(--accent-primary-soft);
transform: translate3d(var(--glider-x, 0px), var(--glider-y, 0px), 0);
opacity: 0;
pointer-events: none;
z-index: 0;
will-change: transform, width;
}
.segmented.has-glider .seg-glider {
opacity: 1;
}
.seg-glider.is-ready {
transition:
transform var(--dur-fast) var(--ease-fast),
width var(--dur-fast) var(--ease-fast),
height var(--dur-fast) var(--ease-fast);
}
.seg-btn {
position: relative;
z-index: 1;
display: inline-flex;
align-items: center;
justify-content: center;
@@ -587,6 +634,7 @@
min-height: calc(22px * var(--ui-font-scale, 1));
padding: 2px 7px;
border: none;
outline: none;
background: transparent;
color: var(--text-secondary);
font-size: var(--fs-md);
@@ -608,6 +656,17 @@
font-weight: 600;
}
.segmented.has-glider .seg-btn:hover {
background: transparent;
color: var(--text-primary);
}
.segmented.has-glider .seg-btn.is-active {
background: transparent;
color: var(--accent-primary);
font-weight: 600;
}
/* --- 7. 独立槽位自定义滚动条 (Bespoke Custom Scrollbar) --- */
.custom-scroll-host {
position: relative;
+706
View File
@@ -0,0 +1,706 @@
/*
* 实验性现代化无边框主题与流畅动画样式层 (modern-ui.css).
* 仅在根容器或 Shadow Host 携带 [data-modern-ui="true"] 时激活:
* 1. 移除绝大部分面板、矩阵、表格、徽章、按钮、输入框与悬浮窗的 1px 线框及分隔线;
* 2. 面板内部子数据块(如版本更新价格表/当前版本、消费矩阵指标格、汇总折线区)保持透明扁平,绝不套叠二层背景卡片;
* 3. 区分深色与浅色极性 ([data-color-scheme="light" | "dark"]):
* - 深色模式采用柔和提亮顶层卡片与轻薄半透雾面滑槽(绝不混入重黑色块);
* - 浅色模式采用微凉白瓷画布 (#f7f9fb) + 纯白悬浮顶层卡片 (#ffffff) + 纯白立体滑块;
* 4. 全局分段切换器 (.segmented / .long-pill-nav / .settings-thirdnav-bar) 按内容宽度贴合滑动。
*/
:root[data-modern-ui="true"],
:host([data-modern-ui="true"]),
[data-modern-ui="true"] {
--radius-sm: 10px;
--radius-xs: 7px;
--ease-modern: cubic-bezier(0.16, 1, 0.3, 1);
--dur-fast: 180ms;
--dur-normal: 240ms;
--modern-canvas-bg: var(--surface-bg);
--modern-surface-card: color-mix(in srgb, var(--surface-panel) 95.2%, #ffffff 4.8%);
--modern-surface-subtle: color-mix(in srgb, var(--text-primary) 5.2%, transparent);
--modern-surface-hover: color-mix(in srgb, var(--accent-primary) 11%, color-mix(in srgb, var(--text-primary) 4%, transparent));
--modern-card-shadow: none;
--modern-nav-track-bg: var(--modern-surface-card);
--modern-inline-track-bg: color-mix(in srgb, var(--text-primary) 4.2%, transparent);
--modern-glider-bg: color-mix(in srgb, var(--accent-primary) 17%, color-mix(in srgb, var(--text-primary) 4%, transparent));
--modern-glider-shadow: none;
--modern-progress-track: color-mix(in srgb, var(--text-primary) 8%, transparent);
--modern-stripe-bg: rgb(255 255 255 / 0.022);
--text-secondary: color-mix(in srgb, var(--text-primary) 80%, transparent);
--text-muted: color-mix(in srgb, var(--text-primary) 62%, transparent);
--modern-active-accent: color-mix(in srgb, var(--accent-primary) 86%, var(--text-primary) 14%);
--shadow-popover: 0 10px 28px rgb(0 0 0 / 0.28), 0 2px 8px rgb(0 0 0 / 0.14);
--shadow-overlay: 0 22px 52px rgb(0 0 0 / 0.42), 0 4px 16px rgb(0 0 0 / 0.20);
}
:root[data-modern-ui="true"][data-color-scheme="light"],
:host([data-modern-ui="true"][data-color-scheme="light"]),
[data-modern-ui="true"][data-color-scheme="light"] {
--modern-canvas-bg: color-mix(in srgb, var(--surface-bg) 95.5%, hsl(216 34% 48%) 4.5%);
--modern-surface-card: #ffffff;
--modern-surface-subtle: hsl(216 42% 97.2%);
--modern-surface-hover: hsl(216 56% 94.4%);
--modern-card-shadow: 0 1px 3px rgb(15 23 42 / 0.045), 0 4px 14px rgb(15 23 42 / 0.028);
--modern-nav-track-bg: hsl(216 28% 94.2%);
--modern-inline-track-bg: hsl(216 32% 96.2%);
--modern-glider-bg: #ffffff;
--modern-glider-shadow: 0 1px 2px rgb(15 23 42 / 0.08), 0 1px 1px rgb(15 23 42 / 0.04);
--modern-progress-track: hsl(216 28% 93.4%);
--modern-stripe-bg: hsl(216 40% 97.8%);
--text-secondary: color-mix(in srgb, var(--text-primary) 72%, transparent);
--text-muted: color-mix(in srgb, var(--text-primary) 58%, transparent);
--modern-active-accent: var(--accent-primary);
--shadow-popover: 0 10px 28px rgb(15 23 42 / 0.10), 0 2px 8px rgb(15 23 42 / 0.05);
--shadow-overlay: 0 20px 48px rgb(15 23 42 / 0.14), 0 4px 14px rgb(15 23 42 / 0.06);
}
@keyframes anim-modern-view-in {
from {
opacity: 0;
transform: translate3d(0, 5px, 0);
}
to {
opacity: 1;
transform: translate3d(0, 0, 0);
}
}
@keyframes anim-modern-pop-in {
from {
opacity: 0;
transform: translateY(-4px) scale(0.975);
}
to {
opacity: 1;
transform: translateY(0) scale(1);
}
}
@keyframes anim-modern-pop-in-up {
from {
opacity: 0;
transform: translateY(4px) scale(0.975);
}
to {
opacity: 1;
transform: translateY(0) scale(1);
}
}
@keyframes anim-modern-tip-fade {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes anim-modern-step-row-in {
0% {
opacity: 0;
background-color: transparent;
animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
}
20% {
opacity: 0.84;
background-color: color-mix(in srgb, var(--accent-primary) 7.5%, transparent);
animation-timing-function: ease-out;
}
36% {
opacity: 1;
background-color: color-mix(in srgb, var(--accent-primary) 6%, transparent);
animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}
70% {
opacity: 1;
background-color: color-mix(in srgb, var(--accent-primary) 2%, transparent);
animation-timing-function: ease-out;
}
100% {
opacity: 1;
background-color: transparent;
}
}
@keyframes anim-modern-step-cell-in {
from {
transform: translate3d(0, -3px, 0);
}
to {
transform: translate3d(0, 0, 0);
}
}
@keyframes anim-modern-pill-in {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
/* --- 1. 外壳画布、顶层卡片与按量贴合滑动轨道 (Canvas, Top-Level Cards & Fit-Content Sliding Tracks) --- */
html[data-standalone="true"][data-modern-ui="true"] #app-root {
min-height: 100dvh;
background: var(--modern-canvas-bg);
}
html[data-standalone="true"][data-modern-ui="true"] .app-shell {
border-left: none;
border-right: none;
}
[data-modern-ui="true"] .app-shell {
background: var(--modern-canvas-bg);
}
[data-modern-ui="true"] .view-pane {
animation: anim-modern-view-in 220ms var(--ease-modern);
}
[data-modern-ui="true"] .panel,
[data-modern-ui="true"] .session-header {
border: none;
background: var(--modern-surface-card);
box-shadow: var(--modern-card-shadow);
}
[data-modern-ui="true"] .panel .panel {
background: var(--modern-surface-subtle);
box-shadow: none;
}
[data-modern-ui="true"] .long-pill-nav,
[data-modern-ui="true"] .settings-thirdnav-bar {
border: none;
background: var(--modern-nav-track-bg);
}
[data-modern-ui="true"] .settings-subnav-bar {
padding: 0;
border: none;
background: transparent;
}
[data-modern-ui="true"] .segmented {
padding: 2px;
border-radius: var(--radius-xs);
background: var(--modern-inline-track-bg);
}
[data-modern-ui="true"] .settings-subnav-bar .segmented {
padding: 3px;
border-radius: var(--radius-sm);
background: var(--modern-nav-track-bg);
}
[data-modern-ui="true"] .pill-glider {
border: none;
background: var(--modern-glider-bg);
box-shadow: var(--modern-glider-shadow);
transition: transform 230ms var(--ease-modern);
}
[data-modern-ui="true"] .seg-glider {
border: none;
background: var(--modern-glider-bg);
box-shadow: var(--modern-glider-shadow);
}
[data-modern-ui="true"] .seg-glider.is-ready {
transition:
transform 220ms var(--ease-modern),
width 220ms var(--ease-modern),
height 180ms var(--ease-modern);
}
[data-modern-ui="true"] .segmented:not(.has-glider) .seg-btn.is-active {
background: var(--modern-glider-bg);
box-shadow: var(--modern-glider-shadow);
}
[data-modern-ui="true"] .thirdnav-glider {
border: none;
background: var(--modern-glider-bg);
box-shadow: var(--modern-glider-shadow);
transition: transform 220ms var(--ease-modern);
}
[data-modern-ui="true"] .pill-tab,
[data-modern-ui="true"] .seg-btn,
[data-modern-ui="true"] .structure-thirdnav-btn {
transition:
color 160ms var(--ease-modern),
transform 140ms var(--ease-modern);
}
[data-modern-ui="true"] .pill-tab:active,
[data-modern-ui="true"] .seg-btn:active,
[data-modern-ui="true"] .structure-thirdnav-btn:active {
transform: scale(0.97);
}
/* --- 2. 按钮、状态标签、代理徽章与胶囊全面去边框 --- */
[data-modern-ui="true"] .status-tag,
[data-modern-ui="true"] .status-tag.state-running,
[data-modern-ui="true"] .status-tag.state-synced,
[data-modern-ui="true"] .status-tag.state-warn,
[data-modern-ui="true"] .update-badge-btn,
[data-modern-ui="true"] .wm-update-btn,
[data-modern-ui="true"] .wm-hover-update-bar,
:host([data-modern-ui="true"]) .wm-update-btn {
border: none;
}
[data-modern-ui="true"] .icon-btn,
[data-modern-ui="true"] .btn-secondary,
[data-modern-ui="true"] .btn-ghost-sm,
[data-modern-ui="true"] .live-sub-toggle,
[data-modern-ui="true"] .ctx-agent-pill,
[data-modern-ui="true"] .theme-host-chip,
[data-modern-ui="true"] .collapsible-badge {
border: none;
background: var(--modern-surface-subtle);
transition:
background-color 160ms var(--ease-modern),
color 160ms var(--ease-modern),
transform 140ms var(--ease-modern);
}
[data-modern-ui="true"] .session-header .icon-btn {
background: var(--modern-surface-subtle);
}
[data-modern-ui="true"] .icon-btn:hover,
[data-modern-ui="true"] .btn-secondary:hover:not(:disabled),
[data-modern-ui="true"] .btn-ghost-sm:hover:not(:disabled),
[data-modern-ui="true"] .live-sub-toggle:hover,
[data-modern-ui="true"] .ctx-agent-pill:hover,
[data-modern-ui="true"] .theme-host-chip:hover {
border: none;
background: var(--modern-surface-hover);
}
[data-modern-ui="true"] .pill-tab.is-active,
[data-modern-ui="true"] .pill-tab.is-active .svg-icon,
[data-modern-ui="true"] .pill-tab.is-active .pill-tab-badge,
[data-modern-ui="true"] .seg-btn.is-active,
[data-modern-ui="true"] .structure-thirdnav-btn.is-active {
color: var(--modern-active-accent);
}
[data-modern-ui="true"] .live-sub-toggle.is-expanded,
[data-modern-ui="true"] .ctx-agent-pill.is-active,
[data-modern-ui="true"] .theme-host-chip.is-active {
border: none;
color: var(--modern-active-accent);
background: var(--accent-primary-soft);
}
[data-modern-ui="true"] .ctx-agent-pill.is-more-toggle {
color: var(--text-secondary);
}
[data-modern-ui="true"] .btn-ghost-sm:disabled {
opacity: 0.54;
}
[data-modern-ui="true"] .live-sub-row.is-done {
opacity: 0.82;
}
[data-modern-ui="true"] .live-sub-row.is-waiting-sub {
opacity: 0.92;
}
[data-modern-ui="true"] .live-sub-row.is-killed-sub {
opacity: 0.68;
}
[data-modern-ui="true"] .live-sub-toggle-chevron,
[data-modern-ui="true"] .ctx-toggle-chevron {
transition: transform 200ms var(--ease-modern);
}
[data-modern-ui="true"] .ctx-agent-pill.is-pill-entering {
animation: anim-modern-pill-in 180ms ease-out both;
}
[data-modern-ui="true"] .ctx-agent-pill.is-pill-collapsing {
opacity: 0;
transition: opacity 150ms ease-out;
}
[data-modern-ui="true"] .btn-primary {
border: none;
transition:
opacity 160ms var(--ease-modern),
transform 140ms var(--ease-modern);
}
[data-modern-ui="true"] .agent-badge,
[data-modern-ui="true"] .agent-badge.is-clickable:hover {
border: none;
}
[data-modern-ui="true"] .agent-badge:not(.badge-main):not([class*="badge-sub-"]) {
background: var(--modern-surface-subtle);
}
/* --- 3. 实时概览矩阵与任务卡片:顶层独立卡片,面板内子块绝不叠套背景 --- */
[data-modern-ui="true"] .telemetry-matrix {
border: none;
background: transparent;
gap: 6px;
overflow: visible;
}
[data-modern-ui="true"] .matrix-cell {
background: var(--modern-surface-card);
box-shadow: var(--modern-card-shadow);
border-radius: var(--radius-sm);
padding: 8px 10px;
transition: background-color 160ms var(--ease-modern);
}
/* 面板内的双栏信息项(如版本更新中的「价格表 / 当前版本」)不套二层背景 */
[data-modern-ui="true"] .dual-grid > .matrix-cell {
background: transparent;
box-shadow: none;
border-radius: 0;
padding: 2px 0;
}
/* 结构页预览画布内的测速卡与任务卡保持轻微层次以呈现真实预览布局 */
[data-modern-ui="true"] .structure-preview-canvas .matrix-cell {
background: var(--modern-surface-subtle);
box-shadow: none;
border-radius: var(--radius-xs);
}
[data-modern-ui="true"] .live-task-card {
border: none;
background: var(--modern-surface-card);
box-shadow: var(--modern-card-shadow);
border-radius: var(--radius-sm);
}
[data-modern-ui="true"] .structure-preview-canvas .live-task-card {
background: var(--modern-surface-subtle);
box-shadow: none;
border-radius: var(--radius-xs);
}
[data-modern-ui="true"] .live-sub-scroll-host {
border-top: none;
padding-top: 6px;
}
[data-modern-ui="true"] .live-sub-scroll-host.is-sub-animating > .scrollbar-rail {
opacity: 0 !important;
pointer-events: none;
}
[data-modern-ui="true"] .progress-track {
border-radius: var(--radius-pill);
background: var(--modern-progress-track);
}
/* --- 4. 用量统计矩阵、热力格与详情卡去边框且不叠内层背景 --- */
[data-modern-ui="true"] .cons-box,
[data-modern-ui="true"] .cons-custom-range-bar {
border: none;
background: transparent;
}
[data-modern-ui="true"] .dt-popover .icon-btn {
background: transparent;
}
[data-modern-ui="true"] .dt-popover .icon-btn:hover {
background: var(--modern-surface-hover);
}
[data-modern-ui="true"] .cons-unified-matrix {
border: none;
background: transparent;
gap: 10px 12px;
padding: 2px 0;
overflow: visible;
}
[data-modern-ui="true"] .cons-split-3 {
gap: 12px;
}
[data-modern-ui="true"] .cons-matrix-bottom {
border-top: none;
}
[data-modern-ui="true"] .cons-col,
[data-modern-ui="true"] .cons-col.is-bordered-col {
border: none;
background: transparent;
border-radius: 0;
padding: 2px 0;
}
[data-modern-ui="true"] .trend-peak-pill,
[data-modern-ui="true"] .trend-hm-cell.lv-0,
[data-modern-ui="true"] .trend-hm-swatch.lv-0 {
border: none;
}
[data-modern-ui="true"] .trend-tip-sub,
[data-modern-ui="true"] .cons-pop-models {
border-top: none;
padding-top: 3px;
}
[data-modern-ui="true"] .cons-source-bar-hit:hover .cons-source-model-bar,
[data-modern-ui="true"] .cons-source-bar-hit.is-hovered .cons-source-model-bar,
[data-modern-ui="true"] .month-col.is-interactive:hover .month-stack,
[data-modern-ui="true"] .month-col.is-hovered .month-stack {
box-shadow: none;
filter: brightness(1.06);
transform: scaleY(1.06);
}
[data-modern-ui="true"] .cons-source-model-bar,
[data-modern-ui="true"] .month-stack {
transition:
height var(--dur-normal) var(--ease-modern),
transform 150ms var(--ease-modern),
filter 150ms var(--ease-modern);
}
/* --- 5. 调用记录表格与模型分析区去横线边框且不套内层背景 --- */
[data-modern-ui="true"] .table-scroll-host {
border-top: none;
background: transparent;
}
[data-modern-ui="true"] .table-viewport,
[data-modern-ui="true"] .data-table th {
background: var(--modern-surface-card);
}
[data-modern-ui="true"] .data-table th,
[data-modern-ui="true"] .data-table td {
border-bottom: none;
}
[data-modern-ui="true"] .data-table tbody tr {
transition: background-color 130ms var(--ease-modern);
}
[data-modern-ui="true"] .steps-data-table tbody tr.is-step-entering {
animation: anim-modern-step-row-in 850ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
[data-modern-ui="true"] .steps-data-table tbody tr.is-step-entering > td {
animation: anim-modern-step-cell-in 300ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
[data-modern-ui="true"] .data-table tbody tr:nth-child(even) {
background: var(--modern-stripe-bg);
}
[data-modern-ui="true"] .data-table tbody tr:hover {
background: var(--modern-surface-hover);
}
[data-modern-ui="true"] .steps-inline-scope-select .select-trigger,
[data-modern-ui="true"] .steps-inline-model-select .select-trigger,
[data-modern-ui="true"] .sstep-fit-model-select .select-trigger {
border: none;
background: var(--modern-surface-subtle);
}
[data-modern-ui="true"] .sstep-card,
[data-modern-ui="true"] .smodel-empty {
border: none;
background: transparent;
padding-left: 2px;
padding-right: 2px;
}
[data-modern-ui="true"] .smodel-card {
border: none;
background: transparent;
}
[data-modern-ui="true"] .step-table-preview-host {
border: none;
background: var(--modern-surface-subtle);
}
[data-modern-ui="true"] .smodel-card:hover {
background: var(--modern-surface-hover);
}
[data-modern-ui="true"] .smodel-card.is-fit-active {
border: none;
background: var(--accent-primary-soft);
}
/* --- 6. 设置表单、折叠面板、槽位排序与输入控件去边框 --- */
[data-modern-ui="true"] .collapsible-body,
[data-modern-ui="true"] .settings-action-block + .settings-action-block,
[data-modern-ui="true"] .settings-account-entry,
[data-modern-ui="true"] .dt-time-row {
border-top: none;
}
[data-modern-ui="true"] .settings-divider {
display: none;
}
[data-modern-ui="true"] .editable-slot-row,
[data-modern-ui="true"] .editable-slot-empty,
[data-modern-ui="true"] .structure-preview-empty,
[data-modern-ui="true"] .preview-sidebar-note,
[data-modern-ui="true"] .preview-capsule-bar,
[data-modern-ui="true"] .preview-capsule-bar.is-composer .wm-multi-btn,
[data-modern-ui="true"] .preview-capsule-bar.is-composer .wm-capsule-btn,
[data-modern-ui="true"] .preview-composer-chip {
border: none;
background: var(--modern-surface-subtle);
}
[data-modern-ui="true"] .slot-add-btn,
[data-modern-ui="true"] .settings-bridge-relaunch-btn {
border: none;
}
[data-modern-ui="true"] .ctx-risk-mask,
[data-modern-ui="true"] .settings-bridge-notice,
[data-modern-ui="true"] .settings-bridge-notice.is-restart {
border: none;
}
[data-modern-ui="true"] .number-input,
[data-modern-ui="true"] .dt-trigger,
[data-modern-ui="true"] .dt-mini-step,
[data-modern-ui="true"] .settings-text-input,
[data-modern-ui="true"] .settings-account-form input {
border: none;
background: var(--modern-surface-subtle);
transition:
background-color 150ms var(--ease-modern),
box-shadow 150ms var(--ease-modern);
}
[data-modern-ui="true"] .num-step-btn {
background: transparent;
}
[data-modern-ui="true"] .num-field {
border-left: none;
border-right: none;
}
[data-modern-ui="true"] .number-input:focus-within,
[data-modern-ui="true"] .settings-text-input:focus,
[data-modern-ui="true"] .settings-account-form input:focus {
border: none;
box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--accent-primary) 55%, transparent);
}
/* --- 7. 全景悬浮窗与工具提示浮层:零边框 + 空气阴影 + 0.15s 平滑跟随过渡 --- */
[data-modern-ui="true"] .select-menu,
[data-modern-ui="true"] .dt-popover,
[data-modern-ui="true"] .sstep-tooltip {
border: none;
background: var(--modern-surface-card);
box-shadow: var(--shadow-popover);
animation: anim-modern-pop-in 150ms var(--ease-modern);
}
[data-modern-ui="true"] .trend-tooltip,
[data-modern-ui="true"] .cons-breakdown-popover,
[data-modern-ui="true"] .turn-prompt-tip {
border: none;
background: var(--modern-surface-card);
box-shadow: var(--shadow-popover);
animation: anim-modern-tip-fade 150ms var(--ease-modern);
}
[data-modern-ui="true"] .trend-tooltip:not(.is-hm-top):not(.is-hm-bottom) {
top: 2px;
bottom: auto;
transform: translate3d(var(--tip-shift, -50%), var(--tip-y, 0px), 0);
}
[data-modern-ui="true"] .trend-tooltip.is-tracking {
transition:
left 150ms var(--ease-modern),
top 150ms var(--ease-modern),
bottom 150ms var(--ease-modern),
transform 150ms var(--ease-modern);
}
[data-modern-ui="true"] .trend-hover-dot.is-tracking {
transition:
cx 150ms var(--ease-modern),
cy 150ms var(--ease-modern);
}
[data-modern-ui="true"] .cons-breakdown-popover.is-tracking,
[data-modern-ui="true"] .turn-prompt-tip.is-tracking {
transition:
left 150ms var(--ease-modern),
top 150ms var(--ease-modern),
transform 150ms var(--ease-modern);
}
[data-modern-ui="true"].wm-popover-panel,
[data-modern-ui="true"].wm-hover-tip,
[data-modern-ui="true"].wm-multi-panel,
:host([data-modern-ui="true"]) .wm-popover-panel,
:host([data-modern-ui="true"]) .wm-hover-tip,
:host([data-modern-ui="true"]) .wm-multi-panel {
border: none;
border-radius: 12px;
background: var(--modern-canvas-bg);
box-shadow: var(--shadow-overlay);
animation: anim-modern-pop-in 200ms var(--ease-modern);
}
[data-modern-ui="true"].wm-popover-panel.is-above,
[data-modern-ui="true"].wm-hover-tip.is-above,
[data-modern-ui="true"].wm-multi-panel.is-above,
:host([data-modern-ui="true"]) .wm-popover-panel.is-above,
:host([data-modern-ui="true"]) .wm-hover-tip.is-above,
:host([data-modern-ui="true"]) .wm-multi-panel.is-above {
animation-name: anim-modern-pop-in-up;
}
[data-modern-ui="true"] .wm-multi-header,
:host([data-modern-ui="true"]) .wm-multi-header,
[data-modern-ui="true"].wm-multi-panel .live-task-card + .live-task-card,
:host([data-modern-ui="true"]) .wm-multi-panel .live-task-card + .live-task-card {
border: none;
}
[data-modern-ui="true"].wm-multi-panel,
:host([data-modern-ui="true"]) .wm-multi-panel {
background: var(--modern-surface-card);
}
[data-modern-ui="true"].wm-multi-panel .live-activity-list,
:host([data-modern-ui="true"]) .wm-multi-panel .live-activity-list {
gap: 2px;
}
[data-modern-ui="true"].wm-multi-panel .live-task-card,
:host([data-modern-ui="true"]) .wm-multi-panel .live-task-card {
padding: 10px 2px;
border-radius: 0;
background: transparent;
box-shadow: none;
}
@@ -14,6 +14,25 @@
gap: 6px;
}
.cons-overview-head .segmented {
gap: 1px;
}
.cons-overview-head .seg-btn {
padding: 2px 6px;
}
.cons-custom-range-bar {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 6px;
padding: 2px 0 0;
background: transparent;
border: none;
border-radius: 0;
}
.cons-badge {
font-size: var(--fs-md);
font-weight: 500;
+34 -18
View File
@@ -172,6 +172,7 @@
background: var(--surface-panel);
border: 1px solid var(--border-hairline);
border-radius: var(--radius-xs);
outline: none;
cursor: pointer;
white-space: nowrap;
transition:
@@ -180,6 +181,15 @@
background-color var(--dur-instant) var(--ease-fast);
}
.live-sub-toggle-chevron {
flex-shrink: 0;
transform: rotate(-90deg);
}
.live-sub-toggle.is-expanded .live-sub-toggle-chevron {
transform: rotate(0deg);
}
.live-sub-toggle:hover {
border-color: var(--border-strong);
color: var(--text-primary);
@@ -260,34 +270,31 @@
flex-shrink: 0;
}
.live-sub-list {
display: flex;
flex-direction: column;
gap: 8px;
.live-sub-scroll-host {
padding-top: 9px;
padding-right: 4px;
margin-top: 3px;
margin-left: 18px;
border-top: 1px dashed var(--border-hairline);
min-width: 0;
}
.live-sub-list {
display: flex;
flex-direction: column;
gap: 8px;
padding-right: 8px;
min-width: 0;
max-height: 196px;
overflow-y: auto;
overscroll-behavior: contain;
scrollbar-width: thin;
scrollbar-color: var(--border-subtle) transparent;
scrollbar-width: none;
-ms-overflow-style: none;
}
.live-sub-list::-webkit-scrollbar {
width: 4px;
}
.live-sub-list::-webkit-scrollbar-track {
background: transparent;
}
.live-sub-list::-webkit-scrollbar-thumb {
background: var(--border-subtle);
border-radius: 999px;
width: 0 !important;
height: 0 !important;
display: none !important;
}
.live-sub-row {
@@ -564,7 +571,7 @@
/* --- 6. 上下文窗口内联代理切换器与代理徽章 (Scheme B Context Inspector & Agent Badges) --- */
.ctx-inspector-bar {
display: flex;
align-items: center;
align-items: flex-start;
width: 100%;
padding: 0;
background: transparent;
@@ -586,6 +593,7 @@
min-height: calc(20px * var(--ui-font-scale, 1));
padding: 1px 6px;
border: 1px solid var(--border-hairline);
outline: none;
background: var(--surface-panel);
color: var(--text-secondary);
font-size: var(--fs-md);
@@ -620,6 +628,14 @@
color: var(--text-primary);
}
.ctx-toggle-chevron {
flex-shrink: 0;
}
.ctx-agent-pill.is-more-toggle.is-expanded .ctx-toggle-chevron {
transform: rotate(180deg);
}
.panel-title .agent-badge {
flex: 0 1 auto;
min-width: 0;
+35 -11
View File
@@ -33,6 +33,7 @@
display: grid;
grid-auto-flow: column;
grid-auto-columns: minmax(0, 1fr);
align-self: stretch;
gap: 3px;
}
@@ -44,13 +45,37 @@
/* --- 结构页三级子导航菜单 (.settings-thirdnav-bar) --- */
.settings-thirdnav-bar {
position: relative;
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 4px;
align-items: center;
padding: 3px;
gap: 0;
background: var(--surface-panel);
border: 1px solid var(--border-hairline);
border-radius: var(--radius-sm);
flex-shrink: 0;
user-select: none;
}
.thirdnav-glider {
position: absolute;
top: 3px;
bottom: 3px;
left: 3px;
width: calc((100% - 6px) / 4);
background: var(--accent-primary-soft);
border: 1px solid var(--accent-primary-border);
border-radius: var(--radius-xs);
transform: translate3d(calc(var(--active-third-index, 0) * 100%), 0, 0);
transition: transform var(--dur-fast) var(--ease-fast);
pointer-events: none;
z-index: 0;
}
.structure-thirdnav-btn {
position: relative;
z-index: 1;
display: inline-flex;
align-items: center;
justify-content: center;
@@ -58,29 +83,28 @@
min-height: calc(25px * var(--ui-font-scale, 1));
min-width: 0;
padding: 2px 6px;
border: 1px solid var(--border-hairline);
border: none;
outline: none;
border-radius: var(--radius-xs);
background: var(--surface-subtle);
background: transparent;
color: var(--text-secondary);
font-size: var(--fs-md);
font-weight: 500;
cursor: pointer;
transition:
background-color var(--dur-instant) var(--ease-fast),
color var(--dur-instant) var(--ease-fast),
border-color var(--dur-instant) var(--ease-fast);
transition: color var(--dur-instant) var(--ease-fast);
}
.structure-thirdnav-btn:focus-visible {
outline: none;
box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--accent-primary) 55%, transparent);
}
.structure-thirdnav-btn:hover {
color: var(--text-primary);
border-color: var(--border-strong);
background: var(--surface-hover);
}
.structure-thirdnav-btn.is-active {
color: var(--accent-primary);
background: var(--accent-primary-soft);
border-color: var(--accent-primary-border);
font-weight: 600;
}
+17 -2
View File
@@ -47,6 +47,7 @@ import { SegmentedControl } from '../components/ui/SegmentedControl.js';
/** 消耗统计顶栏支持的时间范围预设项 */
function getConsumptionTimeRangeOptions() {
return [
{ value: 'cycle', label: t('cons.rangeCycle') },
{ value: 'today', label: t('cons.rangeToday') },
{ value: '24h', label: t('cons.range24h') },
{ value: '7d', label: t('cons.range7d') },
@@ -135,8 +136,7 @@ export const ConsumptionView = defineComponent({
const customRangeBar = h(
'div',
{
style:
'display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 6px 8px; background: var(--surface-subtle); border: 1px solid var(--border-hairline); border-radius: var(--radius-xs);',
className: 'cons-custom-range-bar',
hidden: true,
},
[
@@ -338,6 +338,7 @@ export const ConsumptionView = defineComponent({
activeHoverTargetEl = null;
}
patchAttr(breakdownPopoverEl, 'hidden', true);
patchClasses(breakdownPopoverEl, { 'is-tracking': false });
}
function positionBreakdownPopover(anchorEl, pointerClientX = null) {
@@ -413,8 +414,22 @@ export const ConsumptionView = defineComponent({
},
});
const wasHidden = breakdownPopoverEl.hasAttribute('hidden');
patchAttr(breakdownPopoverEl, 'hidden', false);
positionBreakdownPopover(anchorEl, pointerClientX);
if (wasHidden) {
patchClasses(breakdownPopoverEl, { 'is-tracking': false });
void breakdownPopoverEl.offsetWidth;
if (typeof window !== 'undefined' && typeof window.requestAnimationFrame === 'function') {
window.requestAnimationFrame(() => {
if (!breakdownPopoverEl.hasAttribute('hidden')) {
patchClasses(breakdownPopoverEl, { 'is-tracking': true });
}
});
} else {
patchClasses(breakdownPopoverEl, { 'is-tracking': true });
}
}
}
function createMonthModelSegment() {
+13 -3
View File
@@ -220,7 +220,6 @@ export const StepsDetailView = defineComponent({
collapseAll: true,
multiUnit: t('steps.unitAgent'),
modelValue: selectedAgentScopes,
icon: 'layers',
placeholder: t('steps.allAgents'),
className: 'steps-inline-scope-select',
options: [{ value: 'all', label: t('steps.allAgents') }],
@@ -503,7 +502,7 @@ export const StepsDetailView = defineComponent({
}
}
function renderStepsData(slice) {
function renderStepsData(slice, { allowNewRowFade = false } = {}) {
if (!slice) return;
const uiSt = uiStore.getState();
const locale = getEffectiveLocale();
@@ -729,6 +728,12 @@ export const StepsDetailView = defineComponent({
],
});
const allConversationSteps = hasSubagents
? aggregated?.recentSteps || []
: slice.recentSteps || [];
const shouldAnimateNewRows = Boolean(
allowNewRowFade && slice.experimentalModernUi && !showModels
);
if (!showModels) {
const colKeys = normalizeClientStepColumns(slice.stepTableColumns);
renderStepTable(tableSteps, slice.cascadeId, colKeys, locale, {
@@ -740,6 +745,8 @@ export const StepsDetailView = defineComponent({
showStepSpeedColor: slice.showStepSpeedColor === true,
stepTokenComboFormat: slice.stepTokenComboFormat,
displaySettings,
allConversationSteps,
allowNewRowFade: shouldAnimateNewRows,
});
stepsScroll.refresh();
}
@@ -1070,6 +1077,7 @@ export const StepsDetailView = defineComponent({
st.telemetry?.settings?.stepTokenComboFormat
),
stepTableColumns: st.telemetry?.settings?.stepTableColumns,
experimentalModernUi: Boolean(st.telemetry?.settings?.experimentalModernUi),
}),
(slice) => {
latestSlice = slice;
@@ -1081,7 +1089,9 @@ export const StepsDetailView = defineComponent({
return;
}
isDirty = false;
renderStepsData(slice);
renderStepsData(slice, {
allowNewRowFade: uiStore.getState().stepsSubTab === 'steps',
});
}
);
@@ -6,7 +6,9 @@
import { defineComponent } from '../../core/component.js';
import {
applyAppearanceToRoot,
normalizeClientFontScale,
normalizeClientModernUi,
normalizeClientThemeAccent,
} from '../../core/appearance.js';
import { h, patchAttr, patchClasses, patchText } from '../../core/domPatch.js';
@@ -39,6 +41,13 @@ function getFontScaleOptions() {
];
}
function getModernUiOptions() {
return [
{ value: 'off', label: t('settings.gen.modernUiOff') },
{ value: 'on', label: t('settings.gen.modernUiOn') },
];
}
function getUpdateModeOptions() {
return [
{ value: 'manual', label: t('settings.gen.updateManual') },
@@ -66,6 +75,7 @@ export const SettingsGeneralTab = defineComponent({
let draftLanguage = 'zh-CN';
let draftThemeAccent = 'host';
let draftFontScale = 'md';
let draftModernUi = false;
let draftPluginUpdateMode = 'manual';
let latestSettings = null;
let latestCloudStatus = null;
@@ -123,6 +133,14 @@ export const SettingsGeneralTab = defineComponent({
className: 'settings-hint-text',
text: t('settings.gen.fontHint'),
});
const modernUiLabelEl = h('span', {
className: 'form-label',
text: t('settings.gen.modernUi'),
});
const modernUiHintEl = h('span', {
className: 'settings-hint-text',
text: t('settings.gen.modernUiHint'),
});
const languageSwitch = SegmentedControl({
ariaLabel: t('settings.gen.language'),
@@ -181,6 +199,38 @@ export const SettingsGeneralTab = defineComponent({
},
});
const modernUiSwitch = SegmentedControl({
ariaLabel: t('settings.gen.modernUi'),
modelValue: 'off',
options: getModernUiOptions(),
onUpdateModelValue: async (val) => {
const nextModernUi = val === 'on';
draftModernUi = nextModernUi;
modernUiSwitch.setValue(nextModernUi ? 'on' : 'off');
if (typeof document !== 'undefined' && document.documentElement) {
applyAppearanceToRoot(
document.documentElement,
{
...(latestSettings || {}),
themeAccent: draftThemeAccent,
fontScale: draftFontScale,
experimentalModernUi: nextModernUi,
},
{ includeFontScale: true }
);
}
showAppearanceFeedback(t('settings.saving'), 0);
try {
await saveSettingsPatch({ experimentalModernUi: nextModernUi });
showAppearanceFeedback(t('settings.saved'), 1500);
props.onLayoutChange?.();
} catch {
if (latestSettings) renderSettings(latestSettings);
showAppearanceFeedback(t('settings.saveFailed'), 2500);
}
},
});
const appearancePanel = h('section', { className: 'panel' }, [
h('div', { className: 'panel-header' }, [
h('span', { className: 'panel-title' }, [
@@ -192,6 +242,7 @@ export const SettingsGeneralTab = defineComponent({
h('div', { className: 'form-row' }, [langLabelEl, languageSwitch.el]),
h('div', { className: 'form-row' }, [accentLabelEl, themeColorPicker.el]),
h('div', { className: 'form-row' }, [fontLabelEl, fontScaleSwitch.el, fontHintEl]),
h('div', { className: 'form-row' }, [modernUiLabelEl, modernUiSwitch.el, modernUiHintEl]),
]);
// --- Card 2: 版本更新 ---
@@ -350,6 +401,7 @@ export const SettingsGeneralTab = defineComponent({
draftLanguage = normalizeI18nLanguage(settings.language);
draftThemeAccent = normalizeClientThemeAccent(settings.themeAccent);
draftFontScale = normalizeClientFontScale(settings.fontScale);
draftModernUi = normalizeClientModernUi(settings.experimentalModernUi);
draftPluginUpdateMode = normalizeClientUpdateMode(
settings.pluginUpdateMode,
settings.autoUpdatePlugin
@@ -364,6 +416,10 @@ export const SettingsGeneralTab = defineComponent({
modelValue: draftFontScale,
options: getFontScaleOptions(),
});
modernUiSwitch.setProps({
modelValue: draftModernUi ? 'on' : 'off',
options: getModernUiOptions(),
});
autoUpdateSelect.setProps({
modelValue: draftPluginUpdateMode,
options: getUpdateModeOptions(),
@@ -425,6 +481,8 @@ export const SettingsGeneralTab = defineComponent({
patchText(accentLabelEl, t('settings.gen.themeAccent'));
patchText(fontLabelEl, t('settings.gen.fontScale'));
patchText(fontHintEl, t('settings.gen.fontHint'));
patchText(modernUiLabelEl, t('settings.gen.modernUi'));
patchText(modernUiHintEl, t('settings.gen.modernUiHint'));
patchText(updateTitleEl, t('settings.gen.updateTitle'));
patchText(updateModeLabelEl, t('settings.gen.updateMode'));
patchText(pricingCellLabelEl, t('settings.gen.pricingLabel'));
@@ -441,6 +499,11 @@ export const SettingsGeneralTab = defineComponent({
modelValue: draftFontScale,
options: getFontScaleOptions(),
});
modernUiSwitch.setProps({
ariaLabel: t('settings.gen.modernUi'),
modelValue: draftModernUi ? 'on' : 'off',
options: getModernUiOptions(),
});
autoUpdateSelect.setProps({
modelValue: draftPluginUpdateMode,
options: getUpdateModeOptions(),
@@ -458,6 +521,7 @@ export const SettingsGeneralTab = defineComponent({
languageSwitch.destroy();
themeColorPicker.destroy();
fontScaleSwitch.destroy();
modernUiSwitch.destroy();
autoUpdateSelect.destroy();
});
@@ -467,6 +531,7 @@ export const SettingsGeneralTab = defineComponent({
languageSwitch,
themeColorPicker,
fontScaleSwitch,
modernUiSwitch,
autoUpdateSelect,
syncPricingBtn,
updatePluginBtn,
@@ -7,7 +7,7 @@
*/
import { defineComponent } from '../../core/component.js';
import { h, patchAttr, patchClasses, patchText } from '../../core/domPatch.js';
import { h, patchAttr, patchClasses, patchStyleVar, patchText } from '../../core/domPatch.js';
import { getEffectiveLocale, t } from '../../i18n/index.js';
import { createSvgIcon } from '../../icons/SvgIcon.js';
import {
@@ -177,10 +177,29 @@ export const SettingsStructureTab = defineComponent({
'aria-selected': item.key === activeThirdTab ? 'true' : 'false',
'data-structure-tab': item.key,
onClick: () => {
applyActiveThirdTab(item.key);
if (uiStore.getState().settingsStructureTab !== item.key) {
uiStore.setState({ settingsStructureTab: item.key });
} else {
applyActiveThirdTab(item.key);
}
},
onKeydown: (e) => {
if (e.key === 'ArrowRight' || e.key === 'ArrowLeft') {
e.preventDefault();
const curIdx = Math.max(
0,
STRUCTURE_THIRD_TABS.findIndex((it) => it.key === item.key)
);
const delta = e.key === 'ArrowRight' ? 1 : -1;
const nextIdx =
(curIdx + delta + STRUCTURE_THIRD_TABS.length) % STRUCTURE_THIRD_TABS.length;
const nextItem = STRUCTURE_THIRD_TABS[nextIdx];
if (nextItem) {
applyActiveThirdTab(nextItem.key);
if (uiStore.getState().settingsStructureTab !== nextItem.key) {
uiStore.setState({ settingsStructureTab: nextItem.key });
}
thirdNavBtnMap.get(nextItem.key)?.btn?.focus?.();
}
}
},
},
@@ -190,6 +209,7 @@ export const SettingsStructureTab = defineComponent({
return btn;
});
const thirdNavGlider = h('div', { className: 'thirdnav-glider', 'aria-hidden': 'true' });
const thirdNavBar = h(
'div',
{
@@ -197,7 +217,15 @@ export const SettingsStructureTab = defineComponent({
role: 'tablist',
'aria-label': t('settings.str.thirdTabAria'),
},
thirdNavBtns
[thirdNavGlider, ...thirdNavBtns]
);
patchStyleVar(
thirdNavBar,
'--active-third-index',
Math.max(
0,
STRUCTURE_THIRD_TABS.findIndex((it) => it.key === activeThirdTab)
)
);
// --- Pane 1: 挂载与胶囊栏 (`mount`) ---
@@ -973,6 +1001,11 @@ export const SettingsStructureTab = defineComponent({
function applyActiveThirdTab(nextRawTab) {
const nextTab = normalizeStructureTabKey(nextRawTab);
activeThirdTab = nextTab;
const activeIdx = Math.max(
0,
STRUCTURE_THIRD_TABS.findIndex((it) => it.key === nextTab)
);
patchStyleVar(thirdNavBar, '--active-third-index', activeIdx);
for (const [key, entry] of thirdNavBtnMap.entries()) {
const isActive = key === nextTab;
patchClasses(entry.btn, { 'is-active': isActive });