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(mobile): use original task state for companion cards

Chris8b807c80a168
diff --git a/apps/mobile/src/__tests__/CompanionMessageCard.test.tsx b/apps/mobile/src/__tests__/CompanionMessageCard.test.tsx
index 24ab5247a1..414b1e712b 100644
--- a/apps/mobile/src/__tests__/CompanionMessageCard.test.tsx
+++ b/apps/mobile/src/__tests__/CompanionMessageCard.test.tsx
@@ -11,6 +11,7 @@ const h = vi.hoisted(() => ({
status: 'online',
accountGeneration: 1,
epoch: 1,
+ routeDevice: 'home',
listeners: new Set<any>(),
}));
vi.mock('react-native', () => ({
@@ -50,7 +51,7 @@ vi.mock('react-native', () => ({
vi.mock('@/utils/useGuardedPush', () => ({ useGuardedPush: () => h.push }));
vi.mock('expo-router', () => ({
useFocusEffect: (cb: () => void) => useEffect(cb, [cb]),
- useLocalSearchParams: () => ({ deviceId: 'home' }),
+ useLocalSearchParams: () => ({ deviceId: h.routeDevice }),
useRouter: () => ({ push: h.push }),
}));
vi.mock('react-i18next', async (importOriginal) => ({
@@ -109,6 +110,9 @@ vi.mock('@/hooks/useReduceMotion', () => ({ useReduceMotionEnabled: () => true }
import { CompanionMessageCard } from '@/session/CompanionMessageCard';
import { _clearRemotePathVerdictCache } from '@/session/remotePathVerdict';
import type { NormalizedRemoteMessage } from '@/session/messageNormalize';
+import { remoteSessionStore } from '@/session/remoteSessionStore';
+import type { RemoteSession } from '@/session/types';
+import { SESSION_ACTIVITY_CHANNEL } from '@cindy/device-link';
const message = {
source: { sessionId: 'parent' },
companion: {
@@ -124,7 +128,7 @@ const message = {
let root: Root;
let node: HTMLDivElement;
const render = async () => {
- await act(async () => root.render(createElement(CompanionMessageCard, { message })));
+ await act(async () => root.render(createElement(CompanionMessageCard, { deviceId: 'home', message })));
};
beforeEach(() => {
(globalThis as any).IS_REACT_ACT_ENVIRONMENT = true;
@@ -135,6 +139,8 @@ beforeEach(() => {
h.accountGeneration = 1;
h.epoch = 1;
h.status = 'online';
+ h.routeDevice = 'home';
+ remoteSessionStore.clear();
h.invoke.mockReset();
h.openLink.mockReset().mockResolvedValue({});
h.push.mockReset();
@@ -158,6 +164,39 @@ afterEach(async () => {
vi.useRealTimers();
});
const openEntry = () => node.querySelector<HTMLButtonElement>('[data-testid="companion.taskCard.open"]');
+// Regression: a transcript's resolved host can differ from (or be absent in) route params.
+// Unit: render the production card, assert the query and actual task-opening destination.
+it('uses the transcript host for queries and opening even when the route names another computer', async () => {
+ h.routeDevice = 'other';
+ await act(async () => root.render(createElement(CompanionMessageCard, { deviceId: 'home', message })));
+ expect(h.invoke).toHaveBeenCalledWith('home', 'maker:bot-delegations:list', ['parent']);
+ await act(async () => openEntry()!.click());
+ expect(h.push).toHaveBeenCalledWith({ pathname: '/sessions/[sessionId]', params: { deviceId: 'home', sessionId: 'child' } });
+});
+
+// Previously every test supplied a successful delegation snapshot; none exercised the
+// reported state where the ordinary task list is live but the delegation query fails.
+it('keeps the original task title, live status and opening when the delegation read fails', async () => {
+ remoteSessionStore.setDeviceSessions('home', 'Mac', [{
+ id: 'child', title: 'Original task', status: 'active', agentKind: 'codex',
+ createdAt: '2026-10-20T00:00:00Z', updatedAt: '2026-10-20T00:00:00Z',
+ } as RemoteSession]);
+ remoteSessionStore.applyRemotePush('home', SESSION_ACTIVITY_CHANNEL, {
+ sessionId: 'child', phase: 'running', compactDetail: 'Checking the fix',
+ });
+ h.invoke.mockRejectedValue(new Error('BACKPRESSURE'));
+ await render();
+ expect(node.textContent).toContain('Original task');
+ expect(node.textContent).toContain('devices.companions.status.running');
+ expect(node.textContent).not.toContain('devices.companions.status.unknown');
+ await act(async () => openEntry()!.click());
+ expect(h.push).toHaveBeenCalledWith({ pathname: '/sessions/[sessionId]', params: { deviceId: 'home', sessionId: 'child' } });
+ await act(async () => remoteSessionStore.applyRemotePush('home', SESSION_ACTIVITY_CHANNEL, {
+ sessionId: 'child', phase: 'needs-interaction', attention: true,
+ }));
+ expect(node.textContent).toContain('devices.companions.status.waiting');
+});
+
it('opens the task from the whole card and keeps stop as a small action while it runs', async () => {
await render();
expect(openEntry()?.disabled).toBe(false);
@@ -165,6 +204,32 @@ it('opens the task from the whole card and keeps stop as a small action while it
expect(node.textContent).toContain('devices.companions.stopTask');
});
+it('reads the original task outside the loaded list and keeps renewed running state after a completed delegation', async () => {
+ h.invoke.mockImplementation(async (_device, channel) => channel === 'local-db:sessions:get'
+ ? { id: 'child', title: 'Updated task title' }
+ : { ok: true, delegations: [{ id: 'job', childSessionId: 'child', status: 'completed', title: 'Old title' }] });
+ await render();
+ expect(node.textContent).toContain('Updated task title');
+ expect(node.textContent).toContain('devices.companions.status.completed');
+ await act(async () => {
+ remoteSessionStore.setDeviceSessions('home', 'Mac', [{ id: 'child', title: 'Updated task title', status: 'active' } as RemoteSession]);
+ remoteSessionStore.applyRemotePush('home', SESSION_ACTIVITY_CHANNEL, { sessionId: 'child', phase: 'running' });
+ });
+ expect(node.textContent).toContain('devices.companions.status.running');
+ expect(node.textContent).not.toContain('devices.companions.status.completed');
+});
+
+it('does not borrow another computer\'s task identity or activity for the same id', async () => {
+ remoteSessionStore.setDeviceSessions('other', 'Other Mac', [{ id: 'child', title: 'Unrelated task', status: 'active' } as RemoteSession]);
+ remoteSessionStore.applyRemotePush('other', SESSION_ACTIVITY_CHANNEL, { sessionId: 'child', phase: 'running' });
+ h.invoke.mockRejectedValue(new Error('read failed'));
+ await render();
+ expect(node.textContent).not.toContain('Unrelated task');
+ expect(node.textContent).toContain('devices.companions.status.unknown');
+ expect(openEntry()?.disabled).toBe(true);
+ expect(h.invoke).not.toHaveBeenCalledWith('home', 'local-db:sessions:get', ['child']);
+});
+
it('keeps the task card when the host omits delegations or sends a broken status', async () => {
h.invoke.mockResolvedValue({ ok: true });
await render();
@@ -186,7 +251,7 @@ it('isolates a broken private-chat card so the session can keep rendering', asyn
companion: { kind: 'direct', meta: null },
} as unknown as NormalizedRemoteMessage;
const consoleError = vi.spyOn(console, 'error').mockImplementation(() => {});
- await act(async () => root.render(createElement(CompanionMessageCard, { message: broken })));
+ await act(async () => root.render(createElement(CompanionMessageCard, { deviceId: 'home', message: broken })));
consoleError.mockRestore();
expect(node.textContent).toBe('devices.companions.actionFailed');
});
@@ -336,7 +401,7 @@ it('does not derive PRs from task output and does not query a missing child', as
},
} as NormalizedRemoteMessage;
await act(async () =>
- root.render(createElement(CompanionMessageCard, { message: withoutChild })),
+ root.render(createElement(CompanionMessageCard, { deviceId: 'home', message: withoutChild })),
);
expect(node.textContent).not.toContain('devices.companions.viewPr');
expect(h.invoke.mock.calls.every((c) => c[1] === 'maker:bot-delegations:list')).toBe(true);
@@ -369,7 +434,7 @@ it('refreshes associated PR state only while mounted and never replays task acti
expect(node.querySelector('[data-testid="merged-pr"]')).not.toBeNull();
expect(
h.invoke.mock.calls.every((c) =>
- ['maker:bot-delegations:list', 'git-context:pr-refs:list', 'git-context:pr-status'].includes(
+ ['maker:bot-delegations:list', 'local-db:sessions:get', 'git-context:pr-refs:list', 'git-context:pr-status'].includes(
c[1],
),
),
@@ -402,7 +467,7 @@ it('drops an old child PR response after switching to a different task', async (
meta: { ...(message.companion as any).meta, childSessionId: 'other-child' },
},
} as NormalizedRemoteMessage;
- await act(async () => root.render(createElement(CompanionMessageCard, { message: other })));
+ await act(async () => root.render(createElement(CompanionMessageCard, { deviceId: 'home', message: other })));
await act(async () =>
finish([{ id: 'old', sessionId: 'child', owner: 'private', repo: 'old', prNumber: 1 }]),
);
@@ -541,7 +606,7 @@ it('shows only delivery status even when a legacy task trace contains full instr
body: '读取 /workspace/project/AGENTS.md 并核对执行授权。',
companion: { kind: 'task', meta: { ...message.companion!.meta, role: 'interjection' } },
} as NormalizedRemoteMessage;
- await act(async () => root.render(createElement(CompanionMessageCard, { message: trace })));
+ await act(async () => root.render(createElement(CompanionMessageCard, { deviceId: 'home', message: trace })));
expect(node.textContent).toBe('devices.companions.messageSent');
expect(h.invoke).not.toHaveBeenCalled();
});
@@ -556,7 +621,7 @@ it('opens a stable completed result inline and routes its artifact to the child
role: 'delegation-result', result: { runSequence: 2, status: 'completed', text: 'Second execution result', artifacts: [{ absolutePath: '/reports/result.pdf' }] },
} },
} as NormalizedRemoteMessage;
- await act(async () => root.render(createElement(CompanionMessageCard, { message: resultMessage })));
+ await act(async () => root.render(createElement(CompanionMessageCard, { deviceId: 'home', message: resultMessage })));
// Collapsed: a short preview only; the files come with the full result.
const fileButton = () => [...node.querySelectorAll('button')].find(button => button.textContent === 'result.pdf');
expect(node.textContent).toContain('Second execution result');
@@ -675,7 +740,7 @@ it.each(['sent', 'received'] as const)('keeps a compact %s private-message entry
direction, peerBotName: 'Aster', peerBotId: 'peer', viewerBotId: 'viewer', threadId: 'thread',
preview: 'Synthetic private transport body',
} } } as NormalizedRemoteMessage;
- await act(async () => root.render(createElement(CompanionMessageCard, { message: direct })));
+ await act(async () => root.render(createElement(CompanionMessageCard, { deviceId: 'home', message: direct })));
expect(node.textContent).toContain(`devices.companions.${direction === 'sent' ? 'sentTo' : 'receivedFrom'}`);
expect(node.textContent).not.toContain('Synthetic private transport body');
await act(async () => node.querySelector('button')!.click());
@@ -688,7 +753,7 @@ it('shows the starting state until the first read settles, then the background-t
let finish!: (value: unknown) => void;
h.invoke.mockReturnValue(new Promise((resolve) => { finish = resolve; }));
const untitled = { ...message, companion: { kind: 'task', meta: { ...message.companion!.meta, objective: ' ' } } } as NormalizedRemoteMessage;
- await act(async () => root.render(createElement(CompanionMessageCard, { message: untitled })));
+ await act(async () => root.render(createElement(CompanionMessageCard, { deviceId: 'home', message: untitled })));
expect(node.textContent).toContain('devices.companions.status.queued');
expect(node.textContent).not.toContain('devices.companions.status.unknown');
expect(node.textContent).toContain('devices.companions.backgroundTask');
@@ -713,9 +778,9 @@ it('shows the peer portrait and current name from the cached roster in the priva
const direct = { ...message, key: 'trace-peer', companion: { kind: 'direct', meta: {
direction: 'sent', peerBotName: 'Aster', peerBotId: 'peer', viewerBotId: 'viewer', threadId: 'thread', preview: '',
} } } as NormalizedRemoteMessage;
- await act(async () => root.render(createElement(CompanionMessageCard, { message: direct })));
+ await act(async () => root.render(createElement(CompanionMessageCard, { deviceId: 'home', message: direct })));
expect(node.querySelector('[data-testid="peer-avatar"]')?.textContent).toBe('Aster Renamed');
- await cache.clearRemoteResourceCache();
+ await act(async () => cache.clearRemoteResourceCache());
});
it.each([false, true])('uses the %s receipt title source without replacing frozen results with live state', async (frozen) => {
@@ -725,7 +790,7 @@ it.each([false, true])('uses the %s receipt title source without replacing froze
text: 'Original result', artifacts: [] },
} } } as NormalizedRemoteMessage;
h.invoke.mockResolvedValue({ ok: true, delegations: [{ id: 'job', title: 'Known task title', status: 'running', resultSummary: 'New output' }] });
- await act(async () => root.render(createElement(CompanionMessageCard, { message: receipt })));
+ await act(async () => root.render(createElement(CompanionMessageCard, { deviceId: 'home', message: receipt })));
expect(node.textContent).toContain(frozen ? 'Original title' : 'Known task title');
expect(node.textContent).not.toContain('Full execution instructions');
expect(node.textContent).toContain('devices.companions.status.completed');
@@ -742,7 +807,7 @@ it('keeps legacy results available when their task cannot be read', async () =>
result: { runSequence: 1, status: 'failed', text: 'Saved result', artifacts: [] },
} } } as NormalizedRemoteMessage;
h.invoke.mockRejectedValue(new Error('offline'));
- await act(async () => root.render(createElement(CompanionMessageCard, { message: receipt })));
+ await act(async () => root.render(createElement(CompanionMessageCard, { deviceId: 'home', message: receipt })));
expect(node.textContent).toContain('First line');
expect(node.textContent).not.toContain('Other instructions');
await act(async () => node.querySelector('button')!.click());
diff --git a/apps/mobile/src/session/CompanionMessageCard.tsx b/apps/mobile/src/session/CompanionMessageCard.tsx
index ba7bf9dade..5238958f55 100644
--- a/apps/mobile/src/session/CompanionMessageCard.tsx
+++ b/apps/mobile/src/session/CompanionMessageCard.tsx
@@ -1,7 +1,6 @@
import { formatLocalizedSeconds } from './sessionDurationFormat';
import { CompanionTaskResultCard } from './CompanionTaskResultCard';
import { Component, useEffect, useRef, useState, useSyncExternalStore, type ReactNode } from 'react';
-import { useLocalSearchParams } from 'expo-router';
import { useGuardedPush } from '@/utils/useGuardedPush';
import { Animated, Easing, Linking, Pressable, StyleSheet, View } from 'react-native';
import {
@@ -52,6 +51,7 @@ const TRACE_HIT_SLOP = { top: 6, bottom: 6 } as const;
const AUX_HIT_SLOP = { top: 6, bottom: 6 } as const;
import { useRemoteCompanionQuery } from './useRemoteCompanionQuery';
import { prStatusVisual } from './prStatusVisual';
+import { useCompanionTaskSession } from './useCompanionTaskSession';
class CompanionRenderBoundary extends Component<
{ children: ReactNode; fallback: ReactNode; resetKey: string },
@@ -72,8 +72,9 @@ class CompanionRenderBoundary extends Component<
}
}
-export function CompanionMessageCard({ message, renderMarkdown }: {
+export function CompanionMessageCard({ message, deviceId, renderMarkdown }: {
message: NormalizedRemoteMessage;
+ deviceId: string;
/** The conversation's Markdown renderer for frozen task results. */
renderMarkdown?: (text: string) => ReactNode;
}) {
@@ -84,18 +85,17 @@ export function CompanionMessageCard({ message, renderMarkdown }: {
fallback={<Text style={styles.note}>{t('devices.companions.actionFailed')}</Text>}
resetKey={message.key}
>
- <CompanionMessageCardContent message={message} renderMarkdown={renderMarkdown} />
+ <CompanionMessageCardContent message={message} deviceId={deviceId} renderMarkdown={renderMarkdown} />
</CompanionRenderBoundary>
);
}
-function CompanionMessageCardContent({ message, renderMarkdown }: {
+function CompanionMessageCardContent({ message, deviceId, renderMarkdown }: {
message: NormalizedRemoteMessage;
+ deviceId: string;
renderMarkdown?: (text: string) => ReactNode;
}) {
const { t } = useTranslation();
- const params = useLocalSearchParams<{ deviceId?: string }>();
- const deviceId = typeof params.deviceId === 'string' ? params.deviceId : '';
const styles = useThemedStyles(makeStyles);
const { colors } = useTheme();
const card = message.companion;
@@ -194,19 +194,24 @@ export function CompanionTaskCard({
value?.ok && Array.isArray(value.delegations)
? (value.delegations.find((item) => item.id === meta.delegationId) ?? null)
: null;
- // Desktop parity: until the first read settles the task is still starting;
- // a settled read without this row, or a host that cannot be read, is unverifiable.
+ const childSessionId = row?.childSessionId || meta.childSessionId;
+ const task = useCompanionTaskSession(deviceId, childSessionId);
+ // Like Desktop, the original task can still be running after the delegation settled.
+ // Without either live evidence or a delegation snapshot, keep the unknown/loading state.
const resolved = value !== null || error || !online;
const status =
- row && (BOT_DELEGATION_STATUSES as readonly string[]).includes(row.status)
+ task.activity?.phase === 'needs-interaction' || row?.status === 'waiting' ? 'waiting'
+ : task.running || row?.status === 'running' ? 'running'
+ : task.activity?.phase === 'error' ? 'failed'
+ : task.activity?.phase === 'completed' ? 'completed'
+ : row && (BOT_DELEGATION_STATUSES as readonly string[]).includes(row.status)
? row.status
: resolved ? 'unknown' : 'queued';
- const title = row?.title || meta.objective.trim().split('\n')[0] || t('devices.companions.backgroundTask');
+ const title = task.session?.title || row?.title || meta.objective.trim().split('\n')[0] || t('devices.companions.backgroundTask');
const [pending, setPending] = useState(false);
const [actionFailed, setActionFailed] = useState(false);
const [showPrs, setShowPrs] = useState(false);
const [now, setNow] = useState(Date.now);
- const childSessionId = row?.childSessionId || meta.childSessionId;
const active = Boolean(row && ['queued', 'running', 'waiting'].includes(row.status));
useEffect(() => {
if (!active) return;
@@ -289,12 +294,12 @@ export function CompanionTaskCard({
setPending(false);
}
};
- const openTask = childSessionId ? () => push({
+ const openTask = childSessionId && deviceId && !task.originConflict ? () => push({
pathname: '/sessions/[sessionId]',
params: { deviceId, sessionId: childSessionId },
}) : undefined;
const stale = (!online || error || associated.error || prStatuses.error
- || (Array.isArray(prStatuses.value) && prStatuses.value.some((result) => !result.ok))) && row;
+ || (Array.isArray(prStatuses.value) && prStatuses.value.some((result) => !result.ok))) && (row || task.session);
const facts = [
duration,
Array.isArray(row?.artifacts) && row.artifacts.length > 0 ? t('devices.companions.artifactCount', { count: row.artifacts.length }) : null,
@@ -363,7 +368,7 @@ export function CompanionTaskCard({
</Pressable>
) : null}
{error ? (
- <Pressable accessibilityRole="button" hitSlop={AUX_HIT_SLOP} style={({ pressed }) => [styles.action, pressed && mobileInteractionStyles.pressed]} onPress={refresh}>
+ <Pressable accessibilityRole="button" hitSlop={AUX_HIT_SLOP} style={({ pressed }) => [styles.action, pressed && mobileInteractionStyles.pressed]} onPress={() => { refresh(); task.refresh(); }}>
<Text style={styles.actionLabel}>{t('devices.resources.retry')}</Text>
</Pressable>
) : null}
diff --git a/apps/mobile/src/session/MessageRenderer.tsx b/apps/mobile/src/session/MessageRenderer.tsx
index 6a704ba32b..59c89fa9f3 100644
--- a/apps/mobile/src/session/MessageRenderer.tsx
+++ b/apps/mobile/src/session/MessageRenderer.tsx
@@ -2928,7 +2928,7 @@ const RenderItemView = memo(function RenderItemView({
node = item.message.authorization
? <AuthorizationMessageCard message={item.message} />
: item.message.companion
- ? <CompanionMessageCard message={item.message}
+ ? <CompanionMessageCard message={item.message} deviceId={actions.remoteDeviceId ?? ''}
renderMarkdown={(text) => <CompanionCardMarkdown messageKey={item.key} text={text} actions={actions} />} />
: item.message.orcaCard
? (
diff --git a/apps/mobile/src/session/useCompanionTaskSession.ts b/apps/mobile/src/session/useCompanionTaskSession.ts
new file mode 100644
index 0000000000..a04383ef37
--- /dev/null
+++ b/apps/mobile/src/session/useCompanionTaskSession.ts
@@ -0,0 +1,31 @@
+import { useSyncExternalStore } from 'react';
+import { remoteSessionStore } from './remoteSessionStore';
+import type { RemoteSession } from './types';
+import { useRemoteCompanionQuery } from './useRemoteCompanionQuery';
+
+/** The same original task and live signals as the task list, scoped to its transcript's host. */
+export function useCompanionTaskSession(deviceId: string, sessionId: string | null | undefined) {
+ const cached = useSyncExternalStore(remoteSessionStore.subscribe, () =>
+ remoteSessionStore.getSessions().find((session) => session.id === sessionId) ?? null,
+ );
+ const origin = useSyncExternalStore(remoteSessionStore.subscribe, () =>
+ sessionId ? remoteSessionStore.getSessionDeviceId(sessionId) : undefined,
+ );
+ const originConflict = Boolean(origin && origin !== deviceId && cached?.canonicalDeviceId !== deviceId);
+ const readable = Boolean(deviceId && sessionId && !originConflict);
+ // Reuse the ordinary list's snapshot. A card outside that list can still read its task,
+ // without waiting for the parent delegation list or adding another list-wide fetch.
+ const query = useRemoteCompanionQuery<RemoteSession>(deviceId, 'local-db:sessions:get', [sessionId], {
+ enabled: readable && !cached,
+ });
+ const session = readable
+ ? cached ?? (query.value?.id === sessionId ? query.value : null)
+ : null;
+ const activity = useSyncExternalStore(remoteSessionStore.subscribeHomeStatus, () =>
+ readable ? remoteSessionStore.getSessionLiveActivity(sessionId!) : null,
+ );
+ const running = useSyncExternalStore(remoteSessionStore.subscribeHomeStatus, () =>
+ readable && remoteSessionStore.isSessionRunning(sessionId!),
+ );
+ return { session, activity, running, originConflict, refresh: query.refresh };
+}
diff --git a/docs/product-rules/cindy-bots-runtime.md b/docs/product-rules/cindy-bots-runtime.md
index c2a2da66dc..cd4bc451af 100644
--- a/docs/product-rules/cindy-bots-runtime.md
+++ b/docs/product-rules/cindy-bots-runtime.md
@@ -454,7 +454,7 @@ Session 任务遵守同一套机制与呈现契约:
- **代理恢复选择**:发起伙伴可通过任务专属公共工具查看该任务的当前路由及其下一条已配置候选;
只在本轮执行结束后由伙伴明确选择切换。切换不自动重放工作;伙伴结合原目标和已完成动作,
再决定是否向同一任务发补充消息。未配置的供应商或型号不可擅自加入候选。
-- **任务入口(2026-10-15 改为一张卡)**:Desktop 发起方消息流里,一条后台任务从开始到结束只有一张状态卡(`BotTaskCard`),状态原地变化,不再是下划线文本链接加独立结果卡。卡的第一行是状态字形(排队/运行转圈、等确认蓝点、完成绿点、失败红点)、任务标题(点击进入原任务)与「后台任务 · 引擎 · 用时」;第二行按状态写当前动作与已做时长、等你确认什么、结果摘要或错误;操作收成小胶囊:看看/看过程、补一句(运行中、本机任务才有;回车发送,等同 `message_session_task`)、文件数、PR 状态标、展开/收起结果、停止。标题与 harness 读取同一个 Session;运行状态来自原任务的真实运行信号,不从委派终态推断事项完成。远端伙伴的卡只读。Mobile 继续使用既有任务卡入口,存储与绑定合同不变。
+- **任务入口(2026-10-15 改为一张卡)**:Desktop 发起方消息流里,一条后台任务从开始到结束只有一张状态卡(`BotTaskCard`),状态原地变化,不再是下划线文本链接加独立结果卡。卡的第一行是状态字形(排队/运行转圈、等确认蓝点、完成绿点、失败红点)、任务标题(点击进入原任务)与「后台任务 · 引擎 · 用时」;第二行按状态写当前动作与已做时长、等你确认什么、结果摘要或错误;操作收成小胶囊:看看/看过程、补一句(运行中、本机任务才有;回车发送,等同 `message_session_task`)、文件数、PR 状态标、展开/收起结果、停止。标题与 harness 读取同一个 Session;运行状态来自原任务的真实运行信号,不从委派终态推断事项完成。远端伙伴的卡只读。Mobile 保留既有任务卡布局,查询与打开使用消息列表已解析的所属电脑;标题、运行和等待信号复用普通任务列表的原 Session,列表外任务按原 ID 单条补读。委派读取失败不抹去已知任务状态或禁止进入原任务,无法核实的状态仍显示未知;不同电脑的同 ID 记录不得混用。冻结结果不随续跑改写,存储与绑定合同不变。
**同一个后台任务只有一张脸**:通知、聊天里的卡片与主侧栏进入伙伴开的后台任务都走工程视图 `/cc-agent/:id`(diff、模型选择照常),顶部多一枚「<伙伴> 的后台任务」小标回到该伙伴(只认伙伴自己发起的委派子任务,主人的任务被伙伴接手只有侧栏「在跟进」标记;后台任务归档后从工作台打开仍带这枚小标;结果里的相对链接按该后台任务自己的工作目录解析,不按伙伴主任务目录);伙伴主任务始终 `/bots/:id`,归档历史 `/bots/:id/history/:sid`,群专线回到所属群,不单独开任务页。路由由 `botRouteForOwnedSession` 统一给出,`resolveSessionRoute` 只读已加载的伙伴投影、不等 IPC。
工作台的 Cindy 任务进入与其它条目同一份四组列表(见 6.3),不再另有 `SessionCard` 列表与独立的「已归档」折叠;已归档的负责任务按页接在「做完」最底部,只依据原 `status=archived` 字段,打开只看不取消归档,恢复走条目菜单的显式操作。分页仅为本机可信 renderer 扩展,不向旧远端假报支持。
- **执行结果入口**:Desktop 的冻结结果用同一张后台任务卡呈现(附在收尾回复下时结果默认展开,独立回执默认收起);完成结果属于伙伴收尾回复末尾的紧凑附件,正文先读,卡片与该条回复同列、同一容器归属。宿主以本轮实际消费的完成信号绑定冻结结果,成功收尾后随回复持久保存;同轮多结果分别附上,不按相邻消息、时间或正文猜配,不把所有卡移到时间线末尾。忙时尚未消费的队列不参与当前回复;每个结果还必须有该完成输入持久化之后生成的新正文,旧正文延迟落库、同毫秒无法确认顺序或输入记录缺失时保留独立入口。重复信号不重复绑定,续跑按执行代次保留独立结果。