Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(quota): 设置页余量网格的标题列在窄宽度下可收缩

Dash10a6df045fdc
diff --git a/apps/desktop/src/renderer/components/status/QuotaHoverCard.tsx b/apps/desktop/src/renderer/components/status/QuotaHoverCard.tsx
index dacf2f5074..a6387e2250 100644
--- a/apps/desktop/src/renderer/components/status/QuotaHoverCard.tsx
+++ b/apps/desktop/src/renderer/components/status/QuotaHoverCard.tsx
@@ -172,6 +172,7 @@ function WindowBlock({
<div
id={titleId}
data-severity={severity}
+ title={compact ? title : undefined}
className={cn(
'font-medium tracking-[-0.005em]',
compact ? 'min-w-0 truncate text-13' : 'mb-2 text-14',
@@ -506,10 +507,11 @@ export function QuotaHoverCard({
{!embedded && title && (windows.length > 0 || emptyText) ? <CardDivider /> : null}
{embedded && windowBlocks.length ? (
// 嵌入态各行是 subgrid,共用这里的四列:标题 | 进度条 | 百分比 | 重置倒计时。
- // 窄宽度时倒计时列先收缩截断(全文见 title),进度条再缩到 48px,不横向溢出。
+ // 窄宽度时标题与倒计时列可收缩截断(全文见 title),进度条最小 48px,只有百分比
+ // 保持完整宽度,整体不横向溢出。
<div
data-testid="quota-window-grid"
- className="grid grid-cols-[max-content_minmax(48px,1fr)_max-content_minmax(0,max-content)] gap-x-4 px-4 py-1"
+ className="grid grid-cols-[minmax(0,max-content)_minmax(48px,1fr)_max-content_minmax(0,max-content)] gap-x-4 px-4 py-1"
>
{windowBlocks}
</div>
diff --git a/apps/desktop/src/renderer/components/status/__tests__/QuotaHoverCard.test.tsx b/apps/desktop/src/renderer/components/status/__tests__/QuotaHoverCard.test.tsx
index 45a7cd7eaf..71dc0bfb28 100644
--- a/apps/desktop/src/renderer/components/status/__tests__/QuotaHoverCard.test.tsx
+++ b/apps/desktop/src/renderer/components/status/__tests__/QuotaHoverCard.test.tsx
@@ -130,14 +130,20 @@ describe('QuotaHoverCard', () => {
expect(row.parentElement).toBe(grid);
expect(row.classList.contains('grid-cols-subgrid')).toBe(true);
}
- // 窄宽度:倒计时列可收缩截断,不把余量挤出容器。
- expect(grid.className).toContain('minmax(0,max-content)');
+ // 窄宽度:标题与倒计时列都可收缩截断,只有百分比保持完整,不把余量挤出容器。
+ expect(grid.className).toContain(
+ 'grid-cols-[minmax(0,max-content)_minmax(48px,1fr)_max-content_minmax(0,max-content)]',
+ );
});
- it('keeps the full reset countdown available when the embedded column truncates', () => {
+ it('keeps full title and reset countdown available when embedded columns truncate', () => {
+ const longTitle = 'Claude Very Long Model Display Name 周限';
render(<UsageCard variant="embedded" nowMs={NOW_MS} account={{ windows: [
- { key: 'a', title: '5 小时', window: { utilization: 10, resetsAt: (NOW_MS + 65 * 60_000) / 1000 } },
+ { key: 'a', title: longTitle, window: { utilization: 10, resetsAt: (NOW_MS + 65 * 60_000) / 1000 } },
] }} />);
+ const title = screen.getByText(longTitle);
+ expect(title.classList.contains('truncate')).toBe(true);
+ expect(title.getAttribute('title')).toBe(longTitle);
const countdown = screen.getByText('1小时 5分钟后重置');
expect(countdown.classList.contains('truncate')).toBe(true);
expect(countdown.getAttribute('title')).toBe('1小时 5分钟后重置');