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。

feat(mobile): show aggregated status on collapsed project groups

Dash8f87246a5db8
diff --git a/apps/mobile/src/__tests__/homeDesktopFirst.test.ts b/apps/mobile/src/__tests__/homeDesktopFirst.test.ts
index cb3aaacded..3e6771b51c 100644
--- a/apps/mobile/src/__tests__/homeDesktopFirst.test.ts
+++ b/apps/mobile/src/__tests__/homeDesktopFirst.test.ts
@@ -558,6 +558,11 @@ describe('mobile home desktop-first surface', () => {
expect(projectRowSource).not.toContain('<SquarePen');
expect(projectRowSource).not.toContain('<Ellipsis');
expect(projectRowSource).not.toContain('project.pendingInteractionCount');
+ // 收起组头汇总对齐桌面 ProjectNode:仅收起时计算,运行态走图标呼吸,右槽只放一颗点。
+ expect(desktopProjectNode).toContain('isCollapsed && lamp?.running');
+ expect(projectRowSource).toMatch(/collapsed\s*\?\s*resolveMobileCollapsedGroupStatus\(project\.sessions,/);
+ expect(projectRowSource).toContain('<SessionStatusPulse running={!!collapsedStatus?.running}>');
+ expect(projectRowSource).toContain('home.projectCollapsedStatus.');
expect(projectRowSource).not.toContain('project.subtitle');
expect(sessionRowSource).toContain('titleTestIDPrefix = \'home.sessionRowTitle\'');
expect(sessionRowSource).toContain('`home.sessionRowTitle.${item.session.id}`');
diff --git a/apps/mobile/src/__tests__/sessionRightStatus.test.ts b/apps/mobile/src/__tests__/sessionRightStatus.test.ts
index 90e45ce9d4..c5dd20fdfb 100644
--- a/apps/mobile/src/__tests__/sessionRightStatus.test.ts
+++ b/apps/mobile/src/__tests__/sessionRightStatus.test.ts
@@ -7,7 +7,7 @@
import { describe, expect, it } from 'vitest';
-import { resolveMobileSessionRightStatus } from '../session/sessionRightStatus';
+import { resolveMobileCollapsedGroupStatus, resolveMobileSessionRightStatus } from '../session/sessionRightStatus';
const base = {
liveAttention: false,
@@ -111,3 +111,55 @@ it('unread failed automation is red even without a live activity, and clears aft
expect(resolveMobileSessionRightStatus({ ...base, scheduleUnreadCount: 1, scheduleHasUnreadFailedRun: true, running: true })).toBe('error');
expect(resolveMobileSessionRightStatus({ ...base, scheduleUnreadCount: 0, scheduleHasUnreadFailedRun: false })).toBe('time');
});
+
+describe('resolveMobileCollapsedGroupStatus(收起项目 / 对话组组头,对齐桌面收起项目)', () => {
+ type Row = import('@cindy/maker-shared/session-list').RemoteSessionListItem;
+ const row = (id: string, patch: Partial<Row> = {}): Row => ({
+ session: { id, status: 'active' } as Row['session'],
+ title: id,
+ subtitle: '',
+ detail: '',
+ lastActivityAt: '2026-10-01T00:00:00.000Z',
+ pendingInteractionCount: 0,
+ scheduleInfo: null,
+ ...patch,
+ });
+ const completedUnread = { liveActivity: { sessionId: '', phase: 'completed', compactDetail: '', attention: true } } as const;
+ const errorUnread = { liveActivity: { sessionId: '', phase: 'error', compactDetail: '', attention: true } } as const;
+ const notRunning = () => false;
+
+ it('空闲 / 已读的组头无点、不呼吸', () => {
+ expect(resolveMobileCollapsedGroupStatus([row('a'), row('b')], notRunning)).toEqual({ running: false, dot: null });
+ });
+
+ it('运行态只让图标呼吸,不占右槽', () => {
+ expect(resolveMobileCollapsedGroupStatus([row('a')], (id) => id === 'a')).toEqual({ running: true, dot: null });
+ });
+
+ it('运行与完成未读可同时出现(兄弟任务各自贡献)', () => {
+ expect(resolveMobileCollapsedGroupStatus([row('a'), row('b', completedUnread)], (id) => id === 'a'))
+ .toEqual({ running: true, dot: 'done' });
+ });
+
+ it('任务重新在跑时旧的完成未读不再点绿,出错红点仍保留', () => {
+ expect(resolveMobileCollapsedGroupStatus([row('a', completedUnread)], (id) => id === 'a'))
+ .toEqual({ running: true, dot: null });
+ expect(resolveMobileCollapsedGroupStatus([row('a', errorUnread)], (id) => id === 'a'))
+ .toEqual({ running: true, dot: 'error' });
+ });
+
+ it('多档同时存在时只取最高一档:红 > 蓝 > 绿', () => {
+ const awaiting = row('w', { pendingInteractionCount: 1 });
+ expect(resolveMobileCollapsedGroupStatus([row('d', completedUnread), awaiting], notRunning).dot).toBe('awaiting');
+ expect(resolveMobileCollapsedGroupStatus([row('d', completedUnread), awaiting, row('e', errorUnread)], notRunning).dot)
+ .toBe('error');
+ });
+
+ it('计入自动化组折叠起来的每次运行', () => {
+ const failedRun = row('run-1', { scheduleInfo: { unreadCount: 1, hasUnreadFailedRun: true } as Row['scheduleInfo'] });
+ const latest = row('run-2');
+ const group = { ...latest, automationGroup: { key: 'g', items: [failedRun, latest] } } as unknown as Row;
+ expect(resolveMobileCollapsedGroupStatus([group], notRunning).dot).toBe('error');
+ expect(resolveMobileCollapsedGroupStatus([group], (id) => id === 'run-1').running).toBe(true);
+ });
+});
diff --git a/apps/mobile/src/session/HomeListVisuals.tsx b/apps/mobile/src/session/HomeListVisuals.tsx
index e3b24abe93..abd04c2e5d 100644
--- a/apps/mobile/src/session/HomeListVisuals.tsx
+++ b/apps/mobile/src/session/HomeListVisuals.tsx
@@ -70,7 +70,7 @@ export function SessionStatusMark({
const RUNNING_BREATH_HALF_CYCLE_MS = 750;
const RUNNING_BREATH_MIN_OPACITY = 0.3;
-function SessionStatusPulse({ children, running }: { children: ReactNode; running: boolean }) {
+export function SessionStatusPulse({ children, running }: { children: ReactNode; running: boolean }) {
const reduceMotion = useReduceMotionEnabled();
const animate = running && reduceMotion === false;
const opacity = useRef(new Animated.Value(animate ? RUNNING_BREATH_MIN_OPACITY : 1)).current;
diff --git a/apps/mobile/src/session/HomeSurface.tsx b/apps/mobile/src/session/HomeSurface.tsx
index cd1f5dcda7..14741a3afa 100644
--- a/apps/mobile/src/session/HomeSurface.tsx
+++ b/apps/mobile/src/session/HomeSurface.tsx
@@ -7,7 +7,7 @@ import { ResidentHomeList, useResidentHomeList } from './ResidentHomeList';
import { HomeNewTaskButton } from './HomeNewTaskButton';
import { useRetainedHomeState, getHomeViewSession } from './homeViewSession';
import { rememberRecentTask } from './recentTasks';
-import { homeListStyles, SESSION_ROW_LONG_PRESS_MS, SessionStatusMark } from '@/session/HomeListVisuals';
+import { homeListStyles, SESSION_ROW_LONG_PRESS_MS, SessionStatusMark, SessionStatusPulse } from '@/session/HomeListVisuals';
import { useOptionalHeaderHeight } from '@/session/useOptionalHeaderHeight';
import { SessionHeaderNativeBlur } from "@/session/SessionHeaderNativeControls";
import { rememberComposerEntry } from './composerMorph';
@@ -254,7 +254,11 @@ import {
replaceSessionScheduleIndexEntries,
} from '@/session/scheduleIndex';
import { createScheduleIndexDeferRegistry } from '@/session/scheduleIndexDefer';
-import { latestMobileSessionRow, resolveMobileSessionRowStatus } from '@/session/sessionRightStatus';
+import {
+ latestMobileSessionRow,
+ resolveMobileCollapsedGroupStatus,
+ resolveMobileSessionRowStatus,
+} from '@/session/sessionRightStatus';
import { SessionRightSpinner } from '@/session/SessionRightSpinner';
import { AutomationTimerIcon } from '@/session/AutomationTimerIcon';
import { RenameSessionModal } from '@/session/RenameSessionModal';
@@ -3659,6 +3663,16 @@ function ProjectRow({
isSessionRunning: (sessionId) => remoteSessionStore.isSessionRunning(sessionId),
},
);
+ // 与桌面侧栏收起项目同一规则:仅收起时汇总组内全部任务——任一在跑则组头图标橙色呼吸,
+ // 右槽只放一颗点(出错红 > 等你回复蓝 > 完成未读绿);展开后由子行各自显示,组头不重复。
+ // 运行态命令式读取,依赖 homeStatusVersion 兜底感知变化(理由同上方折叠豁免)。
+ const collapsedStatus = useMemo(
+ () => (collapsed
+ ? resolveMobileCollapsedGroupStatus(project.sessions, (sessionId) => remoteSessionStore.isSessionRunning(sessionId))
+ : null),
+ [collapsed, homeStatusVersion, project.sessions],
+ );
+ const groupIconColor = collapsedStatus?.running ? colors.statusAccent : colors.textSecondary;
const projectHeaderHeight = useSharedValue(HOME_PROJECT_HEADER_HEIGHT);
const projectRef = useAnimatedRef<View>();
const prepareDisclosure = useDisclosurePrepare();
@@ -3770,20 +3784,43 @@ function ProjectRow({
) : (
<ChevronDown color={colors.textSecondary} size={iconSize.xl} strokeWidth={iconStroke.regular} />
)}
- {kind === 'dialogue' ? (
- <MessagesSquare color={colors.textSecondary} size={iconSize.xl} strokeWidth={iconStroke.thin} />
- ) : kind === 'cindy-make' ? (
- <Hammer color={colors.textSecondary} size={iconSize.xl} strokeWidth={iconStroke.thin} />
- ) : collapsed ? (
- <Folder color={colors.textSecondary} size={iconSize.xl} strokeWidth={iconStroke.thin} />
- ) : (
- <FolderOpen color={colors.textSecondary} size={iconSize.xl} strokeWidth={iconStroke.thin} />
- )}
+ <SessionStatusPulse running={!!collapsedStatus?.running}>
+ {kind === 'dialogue' ? (
+ <MessagesSquare color={groupIconColor} size={iconSize.xl} strokeWidth={iconStroke.thin} />
+ ) : kind === 'cindy-make' ? (
+ <Hammer color={groupIconColor} size={iconSize.xl} strokeWidth={iconStroke.thin} />
+ ) : collapsed ? (
+ <Folder color={groupIconColor} size={iconSize.xl} strokeWidth={iconStroke.thin} />
+ ) : (
+ <FolderOpen color={colors.textSecondary} size={iconSize.xl} strokeWidth={iconStroke.thin} />
+ )}
+ </SessionStatusPulse>
<View style={styles.projectLabel}>
<Text style={[styles.projectTitle, styles.projectFolderTitle]} numberOfLines={1}>{project.title}</Text>
{machineIdentity ? <HomeProjectMachineLabel identity={machineIdentity} /> : null}
</View>
<Text style={styles.projectCount} numberOfLines={1}>{project.sessionCount}</Text>
+ {collapsedStatus?.dot ? (
+ // 与任务行右槽同一 18×18 槽、同一右边缘,点色与任务行同表。
+ <View style={styles.sessionRightStatusCell}>
+ <View
+ accessibilityLabel={collapsedStatus.dot === 'error'
+ ? t('devices.list.a11y.taskError')
+ : collapsedStatus.dot === 'awaiting'
+ ? t('devices.list.a11y.awaitingYou')
+ : t('devices.list.a11y.doneUnread')}
+ accessibilityRole="image"
+ style={[styles.sessionRightDot, {
+ backgroundColor: collapsedStatus.dot === 'error'
+ ? colors.statusError
+ : collapsedStatus.dot === 'awaiting'
+ ? colors.statusAwaiting
+ : colors.statusDone,
+ }]}
+ testID={`home.projectCollapsedStatus.${collapsedStatus.dot}.${project.key}`}
+ />
+ </View>
+ ) : null}
</Pressable>
);
return (
diff --git a/apps/mobile/src/session/sessionRightStatus.ts b/apps/mobile/src/session/sessionRightStatus.ts
index fe2252a5b5..56803c1abf 100644
--- a/apps/mobile/src/session/sessionRightStatus.ts
+++ b/apps/mobile/src/session/sessionRightStatus.ts
@@ -79,6 +79,23 @@ export function resolveMobileSessionRightStatus({
);
}
+/** 单个会话行(不含自动化组聚合)的右槽档位;running 为调用方已知的运行态。 */
+function resolveSingleRowStatus(row: SessionRow, running: boolean): MobileSessionRightStatus {
+ return resolveMobileSessionRightStatus({
+ interruption: row.session,
+ livePhase: row.liveActivity?.phase,
+ liveAttention: row.liveActivity?.attention === true,
+ pendingInteractionCount: row.pendingInteractionCount,
+ running: running || isRowRunning(row),
+ scheduleUnreadCount: row.scheduleInfo?.unreadCount ?? 0,
+ scheduleHasUnreadFailedRun: row.scheduleInfo?.hasUnreadFailedRun,
+ });
+}
+
+function isRowRunning(row: SessionRow): boolean {
+ return row.liveActivity?.phase === 'running' || row.scheduleInfo?.running === true;
+}
+
/** Group header mirrors the latest run; collapsed errors remain discoverable. */
export function resolveMobileSessionRowStatus(
item: import('@cindy/maker-shared/session-list').RemoteSessionListItem,
@@ -87,25 +104,50 @@ export function resolveMobileSessionRowStatus(
): { status: MobileSessionRightStatus; target: import('@cindy/maker-shared/session-list').RemoteSessionListItem } {
const children = item.automationGroup?.items;
const latest = latestMobileSessionRow(item);
- const statusOf = (row: typeof item, isRunning: boolean) =>
- resolveMobileSessionRightStatus({
- interruption: row.session,
- livePhase: row.liveActivity?.phase,
- liveAttention: row.liveActivity?.attention === true,
- pendingInteractionCount: row.pendingInteractionCount,
- running:
- isRunning || row.liveActivity?.phase === 'running' || row.scheduleInfo?.running === true,
- scheduleUnreadCount: row.scheduleInfo?.unreadCount ?? 0,
- scheduleHasUnreadFailedRun: row.scheduleInfo?.hasUnreadFailedRun,
- });
- const error = children?.find((row) => statusOf(row, false) === 'error');
- const hasDone = children?.some((row) => statusOf(row, false) === 'done');
+ const error = children?.find((row) => resolveSingleRowStatus(row, false) === 'error');
+ const hasDone = children?.some((row) => resolveSingleRowStatus(row, false) === 'done');
return {
status: resolveCollapsedGroupRightStatus({
collapsed: !expanded,
- latestKind: statusOf(latest, running),
+ latestKind: resolveSingleRowStatus(latest, running),
tone: error ? 'error' : hasDone ? 'done' : null,
}),
target: !expanded && error ? error : latest,
};
}
+
+export type MobileCollapsedGroupDot = 'error' | 'awaiting' | 'done';
+
+export interface MobileCollapsedGroupStatus {
+ /** 组内任一任务在跑:组头图标转橙色呼吸(对齐桌面 ProjectNode 的 lamp.running)。 */
+ running: boolean;
+ /** 组头右槽唯一一颗点:红 > 蓝 > 绿;无需关注时为 null。运行态不占右槽。 */
+ dot: MobileCollapsedGroupDot | null;
+}
+
+const COLLAPSED_DOT_RANK: Record<MobileCollapsedGroupDot, number> = { error: 3, awaiting: 2, done: 1 };
+
+/**
+ * 收起的项目 / 对话组组头汇总(与桌面侧栏收起项目同一规则):
+ * - 计入组内全部任务(含「查看全部」之外、自动化组折叠起来的每次运行),不只看可见前 N 行;
+ * - 每个任务按自己行上的右槽档位取色:出错未读红、等你回复蓝、完成未读绿;
+ * 任务重新在跑时其旧的完成未读不再点绿(行级 running 已压过 done),出错红点照常保留;
+ * - 多个任务同时有点时只显示最高一档;运行态单独返回,由组头图标呼吸表达。
+ */
+export function resolveMobileCollapsedGroupStatus(
+ items: readonly SessionRow[],
+ isSessionRunning: (sessionId: string) => boolean,
+): MobileCollapsedGroupStatus {
+ let running = false;
+ let dot: MobileCollapsedGroupDot | null = null;
+ for (const item of items) {
+ for (const row of item.automationGroup?.items ?? [item]) {
+ const rowRunning = isSessionRunning(row.session.id) || isRowRunning(row);
+ if (rowRunning) running = true;
+ const status = resolveSingleRowStatus(row, rowRunning);
+ if (status === 'running' || status === 'time') continue;
+ if (!dot || COLLAPSED_DOT_RANK[status] > COLLAPSED_DOT_RANK[dot]) dot = status;
+ }
+ }
+ return { running, dot };
+}