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(desktop): 自动任务组头时间与普通任务行同款字体

Dash69b54b0b30dc
diff --git a/apps/desktop/src/renderer/__tests__/automationGeneratedSessions.test.ts b/apps/desktop/src/renderer/__tests__/automationGeneratedSessions.test.ts
index 475e867da0..a84f61cba8 100644
--- a/apps/desktop/src/renderer/__tests__/automationGeneratedSessions.test.ts
+++ b/apps/desktop/src/renderer/__tests__/automationGeneratedSessions.test.ts
@@ -758,8 +758,9 @@ describe('automation-generated sessions', () => {
expect(source).toContain('onClick={openLatestSession}');
expect(source).not.toMatch(/role=\{latestSession \? 'button'/);
expect(source).toContain("group.scheduleStatus === 'active'");
- expect(source).toContain(
- "scheduleId && !menuOpen && 'group-hover:opacity-0 group-focus-within/slot:opacity-0'",
+ // 用正则容忍 prettier 折行(条件在一行还是拆三行都算通过)。
+ expect(source).toMatch(
+ /scheduleId &&\s*!menuOpen &&\s*'group-hover:opacity-0 group-focus-within\/slot:opacity-0'/,
);
expect(source).toContain("menuOpen && 'opacity-0'");
expect(source).toContain('disabled={!latestSession}');
@@ -768,7 +769,9 @@ describe('automation-generated sessions', () => {
// vendor 经 agentKindToVendor 归一(pi 会话显示 π,而非 Claude 脸);尺寸规则:cc=13,其余(codex/pi)=12。
expect(source).toContain("sessionVariant === 'list' ? 'w-3' : 'w-[15px]'");
expect(source).toContain('vendor={agentKindToVendor(latestSession?.agentKind)}');
- expect(source).toContain("size={agentKindToVendor(latestSession?.agentKind) === 'cc' ? 13 : 12}");
+ expect(source).toContain(
+ "size={agentKindToVendor(latestSession?.agentKind) === 'cc' ? 13 : 12}",
+ );
// 所有自动任务统一 Timer;暂停只叠角标,主图标和 12px 槽位不替换。
expect(source).toContain('<AutomationTimerIcon');
expect(source).toContain('paused={isScheduleStopped}');
@@ -782,6 +785,10 @@ describe('automation-generated sessions', () => {
expect(source).toContain('className="flex min-w-0 items-center gap-1.5"');
expect(source).toContain("sessionVariant === 'list' && 'order-2'");
expect(source).toContain('runningSessionIds,');
+ // 组头右侧的时间文字与普通任务行的信息槽(SessionInfoMeta)同款字体 / 色号,
+ // 含 tabular-nums(2026-08-12 用户裁决;C 期给普通行加等宽数字时组头漏跟)。
+ expect(source).toContain("'flex items-center gap-1 text-xs font-medium tabular-nums'");
+ expect(source).toContain("'text-sidebar-action-icon'");
});
it('auto-collapses an expanded automation group once focus leaves it and offers show-all', () => {
diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/AutomationSessionGroupItem.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/AutomationSessionGroupItem.tsx
index d9ba9856ef..3a558cffd3 100644
--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/AutomationSessionGroupItem.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/AutomationSessionGroupItem.tsx
@@ -15,7 +15,10 @@ import {
} from '@/components/ui/dropdown-menu';
import { VendorIcon, agentKindToVendor } from '@/components/sidebar/VendorIcon';
import type { Session } from '@/lib/ccAgent.types';
-import type { AutomationScheduleAction, AutomationSessionGroup } from '../lib/automationSidebarGrouping';
+import type {
+ AutomationScheduleAction,
+ AutomationSessionGroup,
+} from '../lib/automationSidebarGrouping';
import {
getAutomationGroupChildView,
getAutomationGroupLatestSession,
@@ -124,8 +127,7 @@ export function AutomationSessionGroupItem({
// 「已停止」= paused(用户主动暂停)+ expired(计划到期不再触发);两者对用户体验
// 而言都是「不会再自动跑」,视觉上都在 Timer chip 上叠 Pause 徽标,并在 tooltip
// 里显示「已停止」文案,避免用户误判为普通空闲态。
- const isScheduleStopped =
- group.scheduleStatus === 'paused' || group.scheduleStatus === 'expired';
+ const isScheduleStopped = group.scheduleStatus === 'paused' || group.scheduleStatus === 'expired';
const hasVisibleChildren = visibleSessions.length > 0;
// running / loading 也只看最新那条:组头 vendor mark 呼吸 + Timer chip 呼吸 + 右侧
// spinner 都据此,与最新 session 子行一致(需求:「loading 状态和最新的 session 保持一致」)。
@@ -196,10 +198,7 @@ export function AutomationSessionGroupItem({
}
return;
}
- if (
- frozen.hasBeenActive ||
- (activeSessionId ?? null) !== frozen.originActiveSessionId
- ) {
+ if (frozen.hasBeenActive || (activeSessionId ?? null) !== frozen.originActiveSessionId) {
setFrozen(null);
}
}, [activeSessionId, frozen, group.sessions]);
@@ -263,12 +262,11 @@ export function AutomationSessionGroupItem({
const countdownText = shouldTickCountdown
? formatSidebarFutureTime(group.nextFireAt, t, new Date(countdownNowMs))
: '';
- const stoppedText = isScheduleStopped
- ? t('ccAgent.sidebar.automationGroup.stopped')
- : '';
- const runCountText = group.sessions.length > 0
- ? t('ccAgent.sidebar.automationGroup.runCount', { count: group.sessions.length })
- : '';
+ const stoppedText = isScheduleStopped ? t('ccAgent.sidebar.automationGroup.stopped') : '';
+ const runCountText =
+ group.sessions.length > 0
+ ? t('ccAgent.sidebar.automationGroup.runCount', { count: group.sessions.length })
+ : '';
const rowTooltip = useMemo(
() =>
countdownText || stoppedText || runCountText ? (
@@ -303,7 +301,8 @@ export function AutomationSessionGroupItem({
contentClassName={cn(
'bg-[var(--surface-elevated)] text-[var(--text-primary)]',
'border-[var(--border-default)] dark:border-[var(--border-default)] shadow-sm',
- )}>
+ )}
+ >
{/* 行 onClick 只承担鼠标点击空白 = 点击标题的转发;不加 role="button" / tabIndex /
onKeyDown —— ARIA 不允许 role=button widget 内嵌可交互 <button>,且键盘 keydown
会冒泡穿过内部按钮的 stopPropagation(click 语义)造成双触发。键盘可达性由内部
@@ -314,11 +313,7 @@ export function AutomationSessionGroupItem({
// list 组头与普通 SessionCard 共用 10px 内容边距;只有展开后的子任务
// 由下方 pl-3 容器额外缩进。text 模式继续沿用 SessionItem 的树形缩进。
'group relative flex h-8 w-full items-center gap-1.5 rounded-full',
- sessionVariant === 'list'
- ? 'px-2.5'
- : indented
- ? 'pl-[22px] pr-2'
- : 'pl-3 pr-2',
+ sessionVariant === 'list' ? 'px-2.5' : indented ? 'pl-[22px] pr-2' : 'pl-3 pr-2',
'text-left text-sm font-medium',
hasActiveHidden
? 'bg-sidebar-item-active text-[var(--sidebar-item-active-foreground)]'
@@ -349,7 +344,9 @@ export function AutomationSessionGroupItem({
vendor={agentKindToVendor(latestSession?.agentKind)}
size={agentKindToVendor(latestSession?.agentKind) === 'cc' ? 13 : 12}
running={isRunning}
- colorClassName={hasActiveHidden ? 'text-[var(--sidebar-item-active-foreground)]' : undefined}
+ colorClassName={
+ hasActiveHidden ? 'text-[var(--sidebar-item-active-foreground)]' : undefined
+ }
/>
</span>
{/* text 延续 vendor → Timer → 标题;list 把 Timer 排到标题右侧,避免它
@@ -365,9 +362,7 @@ export function AutomationSessionGroupItem({
onClick={(e) => {
e.stopPropagation();
navigate(
- group.scheduleId
- ? scheduleFocusPath(group.scheduleId)
- : '/cc-agent/scheduled',
+ group.scheduleId ? scheduleFocusPath(group.scheduleId) : '/cc-agent/scheduled',
);
}}
onPointerDown={(e) => e.stopPropagation()}
@@ -415,7 +410,11 @@ export function AutomationSessionGroupItem({
<ToggleIcon
size={12}
strokeWidth={2}
- className={hasActiveHidden ? 'text-[var(--sidebar-item-active-foreground)]' : 'text-[var(--cmd-palette-item-meta)]'}
+ className={
+ hasActiveHidden
+ ? 'text-[var(--sidebar-item-active-foreground)]'
+ : 'text-[var(--cmd-palette-item-meta)]'
+ }
/>
</button>
{/* focus 隐藏条件用命名 group(/slot) 收窄到本槽位:行内 toggle/title
@@ -429,9 +428,17 @@ export function AutomationSessionGroupItem({
fade 出让位给 [Run][More] 按钮组。 */}
<div
className={cn(
- 'flex items-center gap-1 text-xs font-medium',
- hasActiveHidden ? 'text-[var(--sidebar-item-active-foreground)]' : 'text-sidebar-action-icon',
- scheduleId && !menuOpen && 'group-hover:opacity-0 group-focus-within/slot:opacity-0',
+ // 字体 / 色号与普通任务行的信息槽(SessionInfoMeta)完全同款——含
+ // tabular-nums(C 期给普通行加的等宽数字,分组头当时漏跟),
+ // 让「9 分钟 / 4 小时」这类时间在两种行里对齐、粗细一致
+ // (2026-08-12 用户裁决)。
+ 'flex items-center gap-1 text-xs font-medium tabular-nums',
+ hasActiveHidden
+ ? 'text-[var(--sidebar-item-active-foreground)]'
+ : 'text-sidebar-action-icon',
+ scheduleId &&
+ !menuOpen &&
+ 'group-hover:opacity-0 group-focus-within/slot:opacity-0',
menuOpen && 'opacity-0',
)}
>
@@ -445,7 +452,11 @@ export function AutomationSessionGroupItem({
>
<span
className="size-2 rounded-full"
- style={{ backgroundColor: hasActiveHidden ? 'var(--sidebar-item-active-foreground)' : 'var(--card-status-error)' }}
+ style={{
+ backgroundColor: hasActiveHidden
+ ? 'var(--sidebar-item-active-foreground)'
+ : 'var(--card-status-error)',
+ }}
aria-hidden
/>
</span>
@@ -458,7 +469,11 @@ export function AutomationSessionGroupItem({
>
<span
className="size-2 rounded-full"
- style={{ backgroundColor: hasActiveHidden ? 'var(--sidebar-item-active-foreground)' : 'var(--card-status-awaiting)' }}
+ style={{
+ backgroundColor: hasActiveHidden
+ ? 'var(--sidebar-item-active-foreground)'
+ : 'var(--card-status-awaiting)',
+ }}
aria-hidden
/>
</span>
@@ -469,7 +484,9 @@ export function AutomationSessionGroupItem({
strokeWidth={2}
className={cn(
'size-4',
- hasActiveHidden ? 'text-sidebar-item-active-foreground' : 'text-sidebar-action-icon',
+ hasActiveHidden
+ ? 'text-sidebar-item-active-foreground'
+ : 'text-sidebar-action-icon',
)}
aria-label={t('ccAgent.sidebar.status.running', 'Running')}
title={t('ccAgent.sidebar.status.running', 'Running')}
@@ -483,7 +500,11 @@ export function AutomationSessionGroupItem({
>
<span
className="size-2 rounded-full"
- style={{ backgroundColor: hasActiveHidden ? 'var(--sidebar-item-active-foreground)' : 'var(--card-status-done)' }}
+ style={{
+ backgroundColor: hasActiveHidden
+ ? 'var(--sidebar-item-active-foreground)'
+ : 'var(--card-status-done)',
+ }}
aria-hidden
/>
</span>
@@ -569,7 +590,10 @@ export function AutomationSessionGroupItem({
<DropdownMenuSeparator className={MENU_SEPARATOR_CLASS} />
<DropdownMenuItem
onSelect={() => onScheduleAction(group, 'delete')}
- disabled={group.scheduleSource === 'project' && (!group.workingDir || !group.projectConfigId)}
+ disabled={
+ group.scheduleSource === 'project' &&
+ (!group.workingDir || !group.projectConfigId)
+ }
className={cn(MENU_ITEM_CLASS, 'text-[hsl(var(--destructive))]')}
>
{t('ccAgent.sidebar.automationGroup.menu.delete')}
diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/sessionCardReviewRegressions.test.ts b/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/sessionCardReviewRegressions.test.ts
index 53259d3620..09bb570528 100644
--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/sessionCardReviewRegressions.test.ts
+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/sessionCardReviewRegressions.test.ts
@@ -56,7 +56,7 @@ describe('SessionCard review regressions', () => {
it('plays overflowing sidebar titles only while hovered', () => {
expect(sessionItemSource).toContain('function SidebarTitleMarquee');
expect(sessionItemSource).toContain("container.dataset.titleOverflowing = 'true'");
- expect(sessionItemSource).toContain("delete container.dataset.titleOverflowing");
+ expect(sessionItemSource).toContain('delete container.dataset.titleOverflowing');
expect(globalsSource).toContain('@keyframes sidebar-title-marquee');
expect(globalsSource).toContain(
"sidebar-title-marquee[data-title-overflowing='true'] .sidebar-title-marquee__track",
@@ -89,7 +89,9 @@ describe('SessionCard review regressions', () => {
});
it('observes layout changes only while the title is hovered', () => {
- expect(sessionItemSource).toContain('const resizeObserverRef = useRef<ResizeObserver | null>(null);');
+ expect(sessionItemSource).toContain(
+ 'const resizeObserverRef = useRef<ResizeObserver | null>(null);',
+ );
expect(sessionItemSource).toContain("typeof ResizeObserver === 'undefined'");
expect(sessionItemSource).toContain('observer.observe(container);');
expect(sessionItemSource).toContain('observer.observe(track);');
@@ -314,16 +316,18 @@ describe('SessionCard review regressions', () => {
});
it('keeps selected automation group icons, spinner, and actions in the active color system', () => {
- expect(automationGroupSource).toContain(
- "colorClassName={hasActiveHidden ? 'text-[var(--sidebar-item-active-foreground)]' : undefined}",
+ // 用正则容忍 prettier 折行(三元在一行还是拆成多行都算通过)。
+ expect(automationGroupSource).toMatch(
+ /colorClassName=\{\s*hasActiveHidden \? 'text-\[var\(--sidebar-item-active-foreground\)\]' : undefined\s*\}/,
);
// running 语义下沉到统一 Timer;组头必须透传,图标组件保持橙色优先级。
expect(automationGroupSource).toContain('running={isRunning}');
expect(automationTimerIconSource).toMatch(
/isActivelyRunning[\s\S]*?\? 'text-\[var\(--status-bar-accent\)\]'/,
);
- expect(automationGroupSource).toContain(
- "hasActiveHidden ? 'text-sidebar-item-active-foreground' : 'text-sidebar-action-icon'",
+ // 用正则容忍 prettier 折行(三元在一行还是拆成多行都算通过)。
+ expect(automationGroupSource).toMatch(
+ /hasActiveHidden\s*\?\s*'text-sidebar-item-active-foreground'\s*:\s*'text-sidebar-action-icon'/,
);
expect(automationGroupSource).toContain('actionButtonToneClassName');
expect(automationGroupSource).toContain(