Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(cindy-make): confirm sources before shared task discovery
MagicLizidcc979742b1d
diff --git a/apps/desktop/src/renderer/features/device-link/SharedTaskDialog.tsx b/apps/desktop/src/renderer/features/device-link/SharedTaskDialog.tsxindex 319a89446a..e9a501b0a9 100644--- a/apps/desktop/src/renderer/features/device-link/SharedTaskDialog.tsx+++ b/apps/desktop/src/renderer/features/device-link/SharedTaskDialog.tsx@@ -20,6 +20,7 @@ import { bindSharedTaskPushOwner, resetRemoteDataOwnerPushFence } from '@/lib/reimport { remoteProjectsStore, isRemoteDeviceMarkedDisconnected } from './remoteProjectsStore';import { sharedTaskErrorKey } from './sharedTaskCompatibility';import { closeOwnedSharedTask } from './closeOwnedSharedTask';+import { filterVisibleSharedTasks } from './sharedTaskVisibility';type Tab = 'join' | 'joined' | 'owned';type Target = { sessionId: string; title: string; deviceId?: string; sharedTaskId?: string; guestId?: string; connect?: boolean };@@ -90,8 +91,10 @@ export function SharedTaskDialog({ open, onOpenChange, session, returnFocus, iniconst items = await window.electronAPI.sharedTask.account({ action: kind === 'owned' ? 'owned' : 'list' });if (!Array.isArray(items)) throw new Error('Invalid shared task list');if (!current()) return;- if (kind === 'owned') setOwned(items as SharedTaskOwnedItem[]);- else setJoined(items as SharedTaskListItem[]);+ const visible = await filterVisibleSharedTasks(items as SharedTaskOwnedItem[], current);+ if (!current()) return;+ if (kind === 'owned') setOwned(visible);+ else setJoined(visible);setListErrors(previous => ({ ...previous, [kind]: false }));} catch {if (current()) setListErrors(previous => ({ ...previous, [kind]: true }));diff --git a/apps/desktop/src/renderer/features/device-link/SharedTasksSection.tsx b/apps/desktop/src/renderer/features/device-link/SharedTasksSection.tsxindex 561e6a4517..8f1b72dd49 100644--- a/apps/desktop/src/renderer/features/device-link/SharedTasksSection.tsx+++ b/apps/desktop/src/renderer/features/device-link/SharedTasksSection.tsx@@ -16,6 +16,7 @@ import { cn } from '@/lib/utils';import { useRemoteProjectSessions, remoteProjectsStore } from './remoteProjectsStore';import { JoinSharedTaskDialog } from './JoinSharedTaskDialog';import { sharedTaskErrorKey } from './sharedTaskCompatibility';+import { filterVisibleSharedTasks } from './sharedTaskVisibility';/** Uses the existing session mirror; choosing a task must not reconnect or fetch it again. */const EMPTY_IDS: ReadonlySet<string> = new Set();@@ -74,7 +75,9 @@ export function SharedTasksSection({ activeSessionId, localSessions = [], runninloading = true;try {const items = await window.electronAPI.sharedTask.account({ action: 'owned' }) as SharedTaskOwnedItem[];- if (captured === epoch.current && isDataOwnerGenerationCurrent(owner)) setOwned(items);+ const current = () => captured === epoch.current && isDataOwnerGenerationCurrent(owner);+ const visible = await filterVisibleSharedTasks(items, current);+ if (current()) setOwned(visible);} catch { /* Retain the last confirmed list during transient network failures. */ }finally { loading = false; }};diff --git a/apps/desktop/src/renderer/features/device-link/__tests__/JoinSharedTaskDialog.test.tsx b/apps/desktop/src/renderer/features/device-link/__tests__/JoinSharedTaskDialog.test.tsxindex d3fc0e4ac1..fc58ac3e84 100644--- a/apps/desktop/src/renderer/features/device-link/__tests__/JoinSharedTaskDialog.test.tsx+++ b/apps/desktop/src/renderer/features/device-link/__tests__/JoinSharedTaskDialog.test.tsx@@ -8,11 +8,13 @@ import { SharedTaskDialog } from '../SharedTaskDialog';import { setDataOwnerGeneration } from '@/contexts/dataOwnerGeneration';import { toast } from '@/lib/toast';-const state = vi.hoisted(() => ({ account: vi.fn(), host: vi.fn(), openLink: vi.fn(), closeLink: vi.fn(), invoke: vi.fn(), setSessions: vi.fn(), mergeSessions: vi.fn(), pin: vi.fn(), captureRead: vi.fn(), removeDevice: vi.fn(), getSessions: vi.fn(), bind: vi.fn(), reset: vi.fn() }));+const state = vi.hoisted(() => ({ account: vi.fn(), host: vi.fn(), openLink: vi.fn(), closeLink: vi.fn(), invoke: vi.fn(), setSessions: vi.fn(), mergeSessions: vi.fn(), pin: vi.fn(), captureRead: vi.fn(), removeDevice: vi.fn(), getSessions: vi.fn(), rawSessions: vi.fn(), findById: vi.fn(), bind: vi.fn(), reset: vi.fn() }));+vi.mock('@/lib/sessionsStore', () => ({ sessionsStore: { findById: state.findById } }));+vi.mock('@/lib/sessionService', () => ({ get: vi.fn() }));vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: (key: string, args?: { title?: string }) => key + (args?.title ? ':' + args.title : '') }) }));vi.mock('@/contexts/AuthContext', () => ({ useAuth: () => ({ dataOwnerId: 'guest', isAuthenticated: true, user: { name: 'Account Guest' } }) }));vi.mock('@/lib/toast', () => ({ toast: { error: vi.fn(), success: vi.fn() } }));-vi.mock('../remoteProjectsStore', () => ({ remoteProjectsStore: { getDeviceName: () => undefined, setDeviceSessions: state.setSessions, mergeDeviceSessions: state.mergeSessions, pinSessionOrigin: state.pin, captureSessionRead: state.captureRead, removeDevice: state.removeDevice, getVisibleMergedRemoteSessions: state.getSessions }, isRemoteDeviceMarkedDisconnected: () => false }));+vi.mock('../remoteProjectsStore', () => ({ remoteProjectsStore: { getDeviceName: () => undefined, setDeviceSessions: state.setSessions, mergeDeviceSessions: state.mergeSessions, pinSessionOrigin: state.pin, captureSessionRead: state.captureRead, removeDevice: state.removeDevice, getVisibleMergedRemoteSessions: state.getSessions, getDeviceSessions: state.rawSessions }, isRemoteDeviceMarkedDisconnected: () => false }));vi.mock('@/lib/remoteDataOwnerPushFence', () => ({ bindSharedTaskPushOwner: state.bind, resetRemoteDataOwnerPushFence: state.reset }));const owned = [{ sharedTaskId: 'own-1', sessionId: 'local-task', ownerAccountId: 'guest', hostDeviceId: 'pc', revision: 1, title: 'First owned task', local: true },@@ -32,6 +34,10 @@ beforeEach(() => {if (action === 'close') { ownedItems = ownedItems.filter(item => item.sharedTaskId !== sharedTaskId); return { closed: [sharedTaskId], failed: [] }; }});state.getSessions.mockReturnValue([]);+ state.findById.mockImplementation(sessionId => ({ id: sessionId, source: 'desktop' }));+ state.rawSessions.mockImplementation((deviceId: string) => [...ownedItems, ...joinedItems]+ .filter(task => task.hostDeviceId === deviceId || sharedTaskHostPeer(task.sharedTaskId, task.hostDeviceId) === deviceId)+ .map(task => ({ id: task.sessionId, source: 'desktop' })));state.captureRead.mockReturnValue(Object.assign(() => true, { mergeActivity: (value: unknown) => value }));state.invoke.mockImplementation(async (_device, channel, [command]) => {if (channel === 'maker:shared-task' && command.action === 'close') {@@ -44,6 +50,30 @@ beforeEach(() => {Object.assign(window, { electronAPI: { sharedTask: { account: state.account, host: state.host }, deviceLink: { openLink: state.openLink, closeLink: state.closeLink, invoke: state.invoke } } });});afterEach(() => { cleanup(); vi.useRealTimers(); });+it.each(['cindy-make', 'cindy-make-merge'])('filters %s from owned and joined account management without the host upgrading', async source => {+ state.rawSessions.mockReturnValue([]);+ state.invoke.mockImplementation(async (_peer, _channel, [sessionId]) => ({ id: sessionId, source }));+ state.findById.mockReturnValue({ id: owned[0].sessionId, source });+ render(<MemoryRouter><SharedTaskDialog open presentation="settings" onOpenChange={vi.fn()} /></MemoryRouter>);+ await screen.findByText('sharedTask.ownedEmptyTitle');+ expect(screen.queryByText(owned[0].title)).toBeNull();+ expect(screen.queryByText(owned[1].title)).toBeNull();+ tab('joined');+ await screen.findByText('sharedTask.joinedEmptyTitle');+ expect(screen.queryByText(joinedTask.title)).toBeNull();+ expect(state.invoke).toHaveBeenCalledWith('other-pc', 'local-db:sessions:get', [owned[1].sessionId]);+ expect(state.invoke).toHaveBeenCalledWith(sharedTaskHostPeer(joinedTask.sharedTaskId, joinedTask.hostDeviceId), 'local-db:sessions:get', [joinedTask.sessionId]);+});+it('does not expose unconfirmed offline shares in account management and retries on focus', async () => {+ ownedItems = [owned[1]]; joinedItems = [];+ state.rawSessions.mockReturnValue([]); state.invoke.mockRejectedValue(new Error('offline'));+ render(<MemoryRouter><SharedTaskDialog open presentation="settings" onOpenChange={vi.fn()} /></MemoryRouter>);+ await screen.findByText('sharedTask.ownedEmptyTitle');+ expect(screen.queryByText(owned[1].title)).toBeNull();+ state.invoke.mockResolvedValue({ id: owned[1].sessionId, source: 'desktop' });+ fireEvent(window, new Event('focus'));+ expect(await screen.findByRole('button', { name: owned[1].title })).toBeTruthy();+});function open(onOpenChange = vi.fn()) {render(<MemoryRouter><SharedTaskDialog open onOpenChange={onOpenChange} /></MemoryRouter>);return onOpenChange;diff --git a/apps/desktop/src/renderer/features/device-link/__tests__/SharedTasksSection.test.tsx b/apps/desktop/src/renderer/features/device-link/__tests__/SharedTasksSection.test.tsxindex baf2af29c9..0e05d15a04 100644--- a/apps/desktop/src/renderer/features/device-link/__tests__/SharedTasksSection.test.tsx+++ b/apps/desktop/src/renderer/features/device-link/__tests__/SharedTasksSection.test.tsx@@ -5,7 +5,9 @@ import { afterEach, beforeEach, expect, it, vi } from 'vitest';import { SharedTasksSection } from '../SharedTasksSection';import { setDataOwnerGeneration } from '@/contexts/dataOwnerGeneration';import type { Session } from '@/lib/ccAgent.types';-const state = vi.hoisted(() => ({ sessions: [] as Session[], account: vi.fn(), openLink: vi.fn(), pin: vi.fn(), row: vi.fn(), mode: 'list' as 'list' | 'text' }));+const state = vi.hoisted(() => ({ sessions: [] as Session[], account: vi.fn(), openLink: vi.fn(), invoke: vi.fn(), getSession: vi.fn(), pin: vi.fn(), row: vi.fn(), mode: 'list' as 'list' | 'text' }));+vi.mock('@/lib/sessionsStore', () => ({ sessionsStore: { findById: () => undefined } }));+vi.mock('@/lib/sessionService', () => ({ get: state.getSession }));vi.mock('@/hooks/useSidebarCardMode', () => ({ useSidebarMainViewMode: () => ({ mode: state.mode }) }));vi.mock('@/features/cc-agent/sidebar/SessionCard', () => ({SessionCard: (props: { session: Session; onClick(): void; sharedTaskRole?: 'owned' | 'joined' }) => {@@ -25,7 +27,7 @@ vi.mock('../JoinSharedTaskDialog', () => ({ JoinSharedTaskDialog: () => null }))vi.mock('@/lib/toast', () => ({ toast: { error: vi.fn() } }));vi.mock('../remoteProjectsStore', () => ({useRemoteProjectSessions: () => state.sessions, isRemoteDeviceMarkedDisconnected: () => false,- remoteProjectsStore: { pinSessionOrigin: state.pin },+ remoteProjectsStore: { pinSessionOrigin: state.pin, getDeviceSessions: (deviceId: string) => state.sessions.filter(session => session.deviceLinkDeviceId === deviceId) },}));const guestTask = { id: 'joined-1', title: 'Joined task', deviceLinkDeviceId: sharedTaskHostPeer('share-1', 'desktop') } as Session;beforeEach(() => {@@ -33,9 +35,35 @@ beforeEach(() => {state.mode = 'list';state.sessions = [guestTask, { id: 'own-device-task', title: 'Own device task', deviceLinkDeviceId: 'my-computer' } as Session];state.account.mockResolvedValue([]);- Object.assign(window, { electronAPI: { sharedTask: { account: state.account }, deviceLink: { openLink: state.openLink } } });+ state.invoke.mockImplementation(async (_peer, _channel, [sessionId]) => ({ id: sessionId, source: 'desktop' }));+ state.getSession.mockImplementation(async sessionId => ({ id: sessionId, source: 'desktop' }));+ Object.assign(window, { electronAPI: { sharedTask: { account: state.account }, deviceLink: { openLink: state.openLink, invoke: state.invoke } } });});afterEach(cleanup);+it.each(['cindy-make', 'cindy-make-merge'])('does not expose a cold legacy %s share or trust another device with the same ID', async source => {+ const item = { sharedTaskId: 'legacy-share', sessionId: 'legacy-task', ownerAccountId: 'guest', hostDeviceId: 'old-host', local: false, title: 'Hidden legacy title' };+ state.account.mockResolvedValue([item]);+ state.sessions = [{ id: item.sessionId, source: 'desktop', deviceLinkDeviceId: 'unrelated-host' } as Session];+ state.invoke.mockResolvedValue({ id: item.sessionId, source });+ render(<SharedTasksSection onSelect={vi.fn()} />);+ await waitFor(() => expect(state.invoke).toHaveBeenCalledWith(item.hostDeviceId, 'local-db:sessions:get', [item.sessionId]));+ await act(async () => {});+ expect(screen.queryByText(item.title)).toBeNull();+ expect(state.openLink).not.toHaveBeenCalled();+});+it('keeps an offline unknown owner share hidden until its ordinary source is confirmed', async () => {+ const item = { sharedTaskId: 'offline-share', sessionId: 'offline-task', ownerAccountId: 'guest', hostDeviceId: 'offline-host', local: false, title: 'Recovered ordinary share' };+ state.account.mockResolvedValue([item]); state.sessions = [];+ state.invoke.mockRejectedValue(new Error('offline'));+ render(<SharedTasksSection onSelect={vi.fn()} />);+ await waitFor(() => expect(state.invoke).toHaveBeenCalled());+ await act(async () => {});+ expect(screen.queryByText(item.title)).toBeNull();+ state.invoke.mockResolvedValue({ id: item.sessionId });+ fireEvent(window, new Event('focus'));+ expect(await screen.findByText(item.title)).toBeTruthy();+ expect(state.openLink).not.toHaveBeenCalled();+});it('uses the ordinary list row with the joined session preview and live status props', async () => {const session = { ...guestTask, preview: 'Latest shared message', agentKind: 'codex' } as Session;state.sessions = [session];@@ -72,7 +100,7 @@ it('uses the local session title and preview instead of device labels and followexpect(onTogglePin).toHaveBeenCalledWith(session.id, false);});it('keeps undiscovered host tasks navigable and only hydrates from the matching host mirror', async () => {- const item = { sharedTaskId: 'owned-1', sessionId: 'host-task', hostDeviceId: 'other-pc', local: false, title: 'Hosted task' };+ const item = { sharedTaskId: 'owned-1', sessionId: 'host-task', ownerAccountId: 'guest', hostDeviceId: 'other-pc', local: false, title: 'Hosted task' };state.account.mockResolvedValue([item]);state.sessions = [{ id: item.sessionId, title: 'Wrong host', preview: 'Wrong preview', deviceLinkDeviceId: 'unrelated-pc' } as Session];state.openLink.mockResolvedValue(undefined);@@ -213,7 +241,7 @@ it('keeps the sidebar empty until sharing starts and hides it when the last owneawait waitFor(() => expect(screen.queryByRole('region')).toBeNull());});it('does not register a remote origin or navigate after an account change during opening', async () => {- state.sessions=[]; state.account.mockResolvedValue([{ sharedTaskId: 'owned-1', sessionId: 'host-task', hostDeviceId: 'other-pc', local: false, title: 'Hosted task' }]);+ state.sessions=[]; state.account.mockResolvedValue([{ sharedTaskId: 'owned-1', sessionId: 'host-task', ownerAccountId: 'guest', hostDeviceId: 'other-pc', local: false, title: 'Hosted task' }]);let finish!: () => void; state.openLink.mockImplementation(() => new Promise<void>(resolve => { finish=resolve; }));const select=vi.fn(); render(<SharedTasksSection onSelect={select} />);fireEvent.click(await screen.findByRole('button', { name: /Hosted task/ }));diff --git a/apps/desktop/src/renderer/features/device-link/sharedTaskVisibility.ts b/apps/desktop/src/renderer/features/device-link/sharedTaskVisibility.tsnew file mode 100644index 0000000000..e907f3f0b8--- /dev/null+++ b/apps/desktop/src/renderer/features/device-link/sharedTaskVisibility.ts@@ -0,0 +1,31 @@+import { sharedTaskHostPeer, type SharedTaskListItem } from '@cindy/device-link';+import { filterCindyMakeSharedTasks } from '@cindy/maker-shared/cindy-make-feature';+import { getDataOwnerGeneration } from '@/contexts/dataOwnerGeneration';+import type { Session } from '@/lib/ccAgent.types';+import * as sessionService from '@/lib/sessionService';+import { sessionsStore } from '@/lib/sessionsStore';+import { remoteProjectsStore } from './remoteProjectsStore';++export function filterVisibleSharedTasks<Task extends SharedTaskListItem & { local?: boolean }>(+ tasks: readonly Task[],+ isCurrent: () => boolean,+) {+ const owner = getDataOwnerGeneration();+ const deviceId = (task: Task) => task.ownerAccountId === owner.dataOwnerId+ ? task.hostDeviceId : sharedTaskHostPeer(task.sharedTaskId, task.hostDeviceId);+ return filterCindyMakeSharedTasks(tasks, {+ isCurrent,+ knownSession: task => task.local+ ? sessionsStore.findById(task.sessionId)+ : remoteProjectsStore.getDeviceSessions(deviceId(task)).find(session => session.id === task.sessionId),+ readSession: async task => {+ if (task.local) return sessionService.get(task.sessionId);+ const peer = deviceId(task);+ if (task.ownerAccountId !== owner.dataOwnerId) {+ await window.electronAPI.deviceLink.openLink(peer);+ if (!isCurrent()) return null;+ }+ return window.electronAPI.deviceLink.invoke(peer, 'local-db:sessions:get', [task.sessionId]) as Promise<Session>;+ },+ });+}diff --git a/apps/mobile/app/shared-session.tsx b/apps/mobile/app/shared-session.tsxindex deddbaf81b..0da4b72ce3 100644--- a/apps/mobile/app/shared-session.tsx+++ b/apps/mobile/app/shared-session.tsx@@ -12,6 +12,7 @@ import { goBackGuarded } from '@/utils/backGuard';import { getMobileAuthOwner, isMobileAuthOwnerCurrent } from '@/auth/authOwnerGeneration';import { useDeviceLink } from '@/device-link/DeviceLinkContext';import { useSharedTaskApi } from '@/device-link/useSharedTaskApi';+import { filterVisibleSharedTasks } from '@/device-link/sharedTaskVisibility';import { sharedTaskErrorKey } from '@/device-link/sharedTaskCompatibility';import { isSharedTaskGone } from '@/device-link/sharedTaskAccessWatch';import { markDeviceAccessRevoked } from '@/device-link/accessRevoked';@@ -83,7 +84,7 @@ export default function SharedSessionScreen() {const current = () => visible() && mounted.current && captured === epoch.current && isMobileAuthOwnerCurrent(owner);if (!isAuthenticated || link.sharedTaskAvailable !== true || ended) return;if (!guestId && (management || tab === 'owned')) {- const value = await api.list();+ const value = await filterVisibleSharedTasks(await api.list(), owner.accountId, link, current);if (!current()) return;const mine = value.filter((task) => task.ownerAccountId === owner.accountId);setOwned(mine);@@ -115,7 +116,7 @@ export default function SharedSessionScreen() {if (guestId && value.detail?.status === 'closed') endAccess();else setState(value);if (hostContext) {- const all = await api.list().catch(() => null);+ const all = await api.list().then(items => filterVisibleSharedTasks(items, owner.accountId, link, current)).catch(() => null);if (current() && all) setOwned(all.filter((task) => task.ownerAccountId === owner.accountId));}} catch (error) {@@ -123,12 +124,12 @@ export default function SharedSessionScreen() {else throw error;}} else {- const value = await api.list();+ const value = await filterVisibleSharedTasks(await api.list(), owner.accountId, link, current);if (current()) {setOwned(value.filter((task) => task.ownerAccountId === owner.accountId));}}- }, [api, ended, endAccess, expectedOwnedSharedTaskId, guestId, host, hostContext, isAuthenticated, link.readDeviceList, link.sharedTaskAvailable, sessionId, tab, management]);+ }, [api, ended, endAccess, expectedOwnedSharedTaskId, guestId, host, hostContext, isAuthenticated, link.invoke, link.openLink, link.readDeviceList, link.sharedTaskAvailable, sessionId, tab, management]);useEffect(() => {mounted.current = true;epoch.current++; pending.current = false; setBusy(false);diff --git a/apps/mobile/src/__tests__/mobileHomeSharedTasks.test.ts b/apps/mobile/src/__tests__/mobileHomeSharedTasks.test.tsindex fd8e3b773a..35f0810b0a 100644--- a/apps/mobile/src/__tests__/mobileHomeSharedTasks.test.ts+++ b/apps/mobile/src/__tests__/mobileHomeSharedTasks.test.ts@@ -54,7 +54,7 @@ describe('shared tasks in the mobile Home', () => {});describe('shared Home group', () => {- const own = { sharedTaskId: 'mine', sessionId: 'owner-task', hostDeviceId: 'desktop', ownerAccountId: 'owner', title: 'My share', revision: 1 };+ const own = { sharedTaskId: 'mine', sessionId: 'owner-task', hostDeviceId: 'desktop', ownerAccountId: 'owner', title: 'My share', revision: 1, source: 'desktop' as string | null | undefined };const split = (sessions: MobileHomeSessionLike[], owned = [own], searchQuery = '', statusFilter: 'active' | 'archived' | 'all' = 'active', selectedDeviceId?: string) => {const home = buildMobileHomePresentation({ sessions, searchQuery, statusFilter, selectedDeviceId, devices: [{ deviceId: 'desktop', name: 'Desktop', canOpen: true },@@ -72,11 +72,16 @@ describe('shared Home group', () => {expect((result.rows.find(row => row.item?.session.id === 'joined')?.item?.session as MobileHomeSessionLike).deviceLinkDeviceId).toBe(peer);});- it('keeps account-discovered owner tasks visible before their device is controllable', () => {+ it('keeps source-confirmed owner tasks visible without a complete session mirror', () => {expect(split([]).rows).toEqual([{ key: 'shared:mine', role: 'owned', task: own }]);expect(split([], []).rows).toEqual([]);});+ it.each([undefined, 'cindy-make', 'cindy-make-merge'])('does not synthesize a share row with source %s', source => {+ expect(split([], [{ ...own, source }]).rows).toEqual([]);+ expect(split([], [{ ...own, source: null }]).rows).toHaveLength(1);+ });+it('moves pinned and project shared tasks into the same group', () => {const result = split([{ ...session('joined', peer, 'Joined'), pinnedAt: '2026-09-21T00:00:00.000Z' },diff --git a/apps/mobile/src/__tests__/sharedTaskFlow.test.tsx b/apps/mobile/src/__tests__/sharedTaskFlow.test.tsxindex adbf81d739..280d627dbc 100644--- a/apps/mobile/src/__tests__/sharedTaskFlow.test.tsx+++ b/apps/mobile/src/__tests__/sharedTaskFlow.test.tsx@@ -16,7 +16,7 @@ const h = vi.hoisted(() => ({router: { replace: vi.fn(), push: vi.fn() }, alert: vi.fn(), revoked: vi.fn(),link: { sharedTaskAvailable: true, invoke: vi.fn(), openLink: vi.fn(), closeLink: vi.fn(), readDeviceList: vi.fn() },api: { list: vi.fn(), get: vi.fn(), join: vi.fn(), leave: vi.fn(), close: vi.fn() },- store: { getSessions: () => [], removeDevice: vi.fn(), setDeviceSessions: vi.fn(), upsertDeviceSession: vi.fn() },+ store: { getSessions: vi.fn(), removeDevice: vi.fn(), setDeviceSessions: vi.fn(), upsertDeviceSession: vi.fn() },t: (key: string, options?: { title?: string; link?: string }) => key === 'sharedTask.invitationMessage' ? `Join “${options?.title}”\n${options?.link}\nOpen the link, or copy it and open Cindy on mobile.` : options?.title ? key + ':' + options.title : key,}));vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: h.t }) }));@@ -70,7 +70,7 @@ vi.mock('@/theme', () => ({ useTheme: () => ({ colors: {} }), useThemedStyles: (let element: HTMLDivElement;let root: Root;const detail = { sharedTaskId: 'shared', sessionId: 'task', hostDeviceId: 'desktop', status: 'active', title: 'Design review', memberLabels: [{ memberId: 'member', displayName: 'Guest' }] };-const owned = (id: string) => ({ sharedTaskId: id, sessionId: 'task', title: id, ownerAccountId: 'owner', hostDeviceId: 'host' });+const owned = (id: string) => ({ sharedTaskId: id.replaceAll(' ', '-'), sessionId: 'task', title: id, ownerAccountId: 'owner', hostDeviceId: 'host' });async function render() { await act(async () => root.render(createElement(SharedSessionScreen))); }async function click(label: string) {// The account page has a Join tab and a Join submit action; use the latter.@@ -89,12 +89,38 @@ beforeEach(() => {Platform.OS = 'android';setMobileAuthOwner('owner'); h.link.sharedTaskAvailable = true;h.api.list.mockResolvedValue([]); h.api.get.mockResolvedValue(detail);+ h.store.getSessions.mockReturnValue(['host', 'desktop', sharedTaskHostPeer('shared', 'desktop'), sharedTaskHostPeer('guest-task', 'host'), sharedTaskHostPeer('Already-joined', 'host')]+ .map(deviceLinkDeviceId => ({ id: 'task', source: 'desktop', deviceLinkDeviceId })));h.api.join.mockResolvedValue({ sharedTaskId: 'shared' });h.link.invoke.mockResolvedValue({ available: true, detail: null });h.link.readDeviceList.mockResolvedValue({ devices: [{ deviceId: 'host', name: 'Test computer' }] });element = document.createElement('div'); root = createRoot(element);});afterEach(async () => { await act(async () => root.unmount()); clearSharedTaskInvitationIntent(); vi.useRealTimers(); });+it.each(['cindy-make', 'cindy-make-merge'])('hides cold %s shares from both account management lists', async source => {+ h.params = { mode: 'manage' };+ h.api.list.mockResolvedValue([owned('Legacy owned'), { ...owned('Legacy joined'), ownerAccountId: 'other' }]);+ h.store.getSessions.mockReturnValue([]);+ h.link.invoke.mockImplementation(async (_peer, _channel, [sessionId]) => ({ id: sessionId, source }));+ await render();+ expect(element.textContent).not.toContain('Legacy owned');+ expect(element.textContent).not.toContain('Legacy joined');+ expect(element.textContent).toContain('sharedTask.ownedEmptyTitle');+ await click('sharedTask.joinedTab');+ expect(element.textContent).toContain('sharedTask.joinedEmptyTitle');+ expect(h.link.invoke).toHaveBeenCalledWith('host', 'local-db:sessions:get', ['task']);+ expect(h.link.invoke).toHaveBeenCalledWith(sharedTaskHostPeer('Legacy-joined', 'host'), 'local-db:sessions:get', ['task']);+});+it('does not show unknown offline shares and restores a confirmed ordinary share on the next poll', async () => {+ h.params = { mode: 'manage' }; h.api.list.mockResolvedValue([owned('Recovered normal task')]);+ h.store.getSessions.mockReturnValue([]); h.link.invoke.mockRejectedValue(new Error('offline'));+ await render();+ expect(element.textContent).not.toContain('Recovered normal task');+ h.link.invoke.mockResolvedValue({ id: 'task', source: 'desktop' });+ await act(async () => vi.advanceTimersByTimeAsync(5_000));+ expect(element.textContent).toContain('Recovered normal task');+ expect(h.link.openLink).not.toHaveBeenCalled();+});const invitationLink = 'https://relay.example.test/shared-task/join#' + 'A'.repeat(43);const invitationIntent = 'cindy://shared-session?invitation=' + 'A'.repeat(43) + '&server=https%3A%2F%2Frelay.example.test';it('copies a shareable invitation message with a link accepted by automatic and manual admission', async () => {@@ -476,7 +502,7 @@ it('opens owner management through the physical host and preserves the settingsh.params = { mode: 'manage' }; h.api.list.mockResolvedValue([owned('My task')]);await render(); await click('sharedTask.manage');expect(h.link.openLink).toHaveBeenCalledWith('host');- expect(h.router.push).toHaveBeenCalledWith({ pathname: '/shared-session', params: { sessionId: 'task', deviceId: 'host', expectedOwnedSharedTaskId: 'My task', mode: 'detail' } });+ expect(h.router.push).toHaveBeenCalledWith({ pathname: '/shared-session', params: { sessionId: 'task', deviceId: 'host', expectedOwnedSharedTaskId: 'My-task', mode: 'detail' } });expect(h.router.replace).not.toHaveBeenCalled();});diff --git a/apps/mobile/src/__tests__/useSharedTasks.test.tsx b/apps/mobile/src/__tests__/useSharedTasks.test.tsxindex 080b891090..a4d15ff6a5 100644--- a/apps/mobile/src/__tests__/useSharedTasks.test.tsx+++ b/apps/mobile/src/__tests__/useSharedTasks.test.tsx@@ -5,13 +5,14 @@ import { afterEach, beforeEach, expect, it, vi } from 'vitest';import { useSharedTasks } from '../device-link/useSharedTasks';import { setMobileAuthOwner } from '@/auth/authOwnerGeneration';import { sharedTaskHostPeer, type SharedTaskListItem } from '@cindy/device-link';+import type { RemoteSession } from '@/session/types';const state = vi.hoisted(() => ({auth: { isAuthenticated: true, accountGeneration: 1 },link: { status: 'online', sharedTaskAvailable: false as boolean | undefined,openLink: vi.fn(), closeLink: vi.fn(), invoke: vi.fn() },api: { list: vi.fn<() => Promise<SharedTaskListItem[]>>(async () => []) },- store: { getSessions: vi.fn(() => []), removeDevice: vi.fn(), setDeviceSessions: vi.fn() },+ store: { getSessions: vi.fn<() => RemoteSession[]>(() => []), removeDevice: vi.fn(), setDeviceSessions: vi.fn() },}));vi.mock('@/auth/AuthContext', () => ({ useAuth: () => state.auth }));vi.mock('@/device-link/DeviceLinkContext', () => ({ useDeviceLink: () => state.link }));@@ -24,24 +25,26 @@ async function render() { await act(async () => root.render(createElement(Probe)beforeEach(() => {Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });vi.useFakeTimers(); vi.resetAllMocks();- state.api.list.mockResolvedValue([]); state.store.getSessions.mockReturnValue([]);+ state.api.list.mockResolvedValue([]);+ state.store.getSessions.mockReturnValue([{ id: 'owned-task', deviceLinkDeviceId: 'desktop', source: 'desktop' } as RemoteSession]);state.auth.isAuthenticated = true; state.auth.accountGeneration = 1;setMobileAuthOwner('owner');state.link.status = 'online'; state.link.sharedTaskAvailable = false;root = createRoot(document.createElement('div'));});const owned = { sharedTaskId: 'owned', sessionId: 'owned-task', ownerAccountId: 'owner', hostDeviceId: 'desktop', title: 'My share', revision: 1 };+const confirmedOwned = { ...owned, source: 'desktop' };it('discovers owner shares without opening guest links or requiring remote control', async () => {state.link.sharedTaskAvailable = true;state.api.list.mockResolvedValue([owned]);await render();- expect(ownedTasks).toEqual([owned]);+ expect(ownedTasks).toEqual([confirmedOwned]);expect(state.link.openLink).not.toHaveBeenCalled();expect(state.link.invoke).not.toHaveBeenCalled();state.link.status = 'connecting'; await render();- expect(ownedTasks).toEqual([owned]);+ expect(ownedTasks).toEqual([confirmedOwned]);state.link.status = 'online'; state.api.list.mockRejectedValue(new Error('offline')); await render();- expect(ownedTasks).toEqual([owned]);+ expect(ownedTasks).toEqual([confirmedOwned]);state.api.list.mockResolvedValue([]);await act(async () => vi.advanceTimersByTimeAsync(5_000));expect(ownedTasks).toEqual([]);@@ -54,13 +57,13 @@ it('keeps guest admission separate while listing shares owned by the same accounstate.api.list.mockResolvedValue([owned, guest]);state.link.invoke.mockResolvedValue({ id: 'guest-task' });await render();- expect(ownedTasks).toEqual([owned]);+ expect(ownedTasks).toEqual([confirmedOwned]);expect(state.link.openLink).toHaveBeenCalledExactlyOnceWith(sharedTaskHostPeer('joined', 'desktop'));expect(state.store.setDeviceSessions).toHaveBeenCalledExactlyOnceWith(sharedTaskHostPeer('joined', 'desktop'), guest.title, [{ id: 'guest-task' }]);});it('hides the previous account shares and ignores its late list response', async () => {state.link.sharedTaskAvailable = true; state.api.list.mockResolvedValue([owned]);- await render(); expect(ownedTasks).toEqual([owned]);+ await render(); expect(ownedTasks).toEqual([confirmedOwned]);let finish!: (value: SharedTaskListItem[]) => void;state.api.list.mockImplementationOnce(() => new Promise(resolve => { finish = resolve; }));await act(async () => vi.advanceTimersByTimeAsync(5_000));@@ -71,6 +74,41 @@ it('hides the previous account shares and ignores its late list response', asyncexpect(ownedTasks).toEqual([]);});afterEach(async () => { await act(async () => root.unmount()); vi.useRealTimers(); });+it.each(['cindy-make', 'cindy-make-merge'])('hides an account-owned legacy %s share without a visible mirror', async source => {+ state.link.sharedTaskAvailable = true; state.api.list.mockResolvedValue([owned]);+ state.store.getSessions.mockReturnValue([{ id: owned.sessionId, deviceLinkDeviceId: 'unrelated-host', source: 'desktop' } as RemoteSession]);+ state.link.invoke.mockResolvedValue({ id: owned.sessionId, source });+ await render();+ expect(ownedTasks).toEqual([]);+ expect(state.link.invoke).toHaveBeenCalledExactlyOnceWith(owned.hostDeviceId, 'local-db:sessions:get', [owned.sessionId]);+ expect(state.link.openLink).not.toHaveBeenCalled();+});+it('uses raw hidden metadata without contacting the offline owner host', async () => {+ state.link.sharedTaskAvailable = true; state.api.list.mockResolvedValue([owned]);+ state.store.getSessions.mockReturnValue([{ id: owned.sessionId, deviceLinkDeviceId: owned.hostDeviceId, source: 'cindy-make' } as RemoteSession]);+ await render();+ expect(ownedTasks).toEqual([]);+ expect(state.link.invoke).not.toHaveBeenCalled();+ expect(state.link.openLink).not.toHaveBeenCalled();+});+it('keeps an offline unknown share hidden and resumes ordinary discovery after source recovery', async () => {+ state.link.sharedTaskAvailable = true; state.api.list.mockResolvedValue([owned]); state.store.getSessions.mockReturnValue([]);+ state.link.invoke.mockRejectedValueOnce(new Error('offline'));+ await render(); expect(ownedTasks).toEqual([]);+ state.link.invoke.mockResolvedValue({ id: owned.sessionId });+ await act(async () => vi.advanceTimersByTimeAsync(5_000));+ expect(ownedTasks).toEqual([{ ...owned, source: null }]);+ expect(state.link.openLink).not.toHaveBeenCalled();+});+it('ignores metadata confirmed after switching accounts', async () => {+ state.link.sharedTaskAvailable = true; state.api.list.mockResolvedValue([owned]); state.store.getSessions.mockReturnValue([]);+ let finish!: (session: { id: string; source: string }) => void;+ state.link.invoke.mockImplementationOnce(() => new Promise(resolve => { finish = resolve; }));+ await render(); expect(ownedTasks).toEqual([]);+ setMobileAuthOwner('other'); state.auth.accountGeneration++; state.api.list.mockResolvedValue([]);+ await render(); await act(async () => finish({ id: owned.sessionId, source: 'desktop' }));+ expect(ownedTasks).toEqual([]);+});it('does not poll an old relay, resumes after upgrade, and pauses without deleting history on disconnect', async () => {await render();await act(async () => vi.advanceTimersByTimeAsync(15_000));diff --git a/apps/mobile/src/device-link/sharedTaskVisibility.ts b/apps/mobile/src/device-link/sharedTaskVisibility.tsnew file mode 100644index 0000000000..fd6b654ca5--- /dev/null+++ b/apps/mobile/src/device-link/sharedTaskVisibility.ts@@ -0,0 +1,28 @@+import { sharedTaskHostPeer, type SharedTaskListItem } from '@cindy/device-link';+import { filterCindyMakeSharedTasks } from '@cindy/maker-shared/cindy-make-feature';+import { remoteSessionStore } from '@/session/remoteSessionStore';+import type { RemoteSession } from '@/session/types';+import type { useDeviceLink } from './DeviceLinkContext';++export function filterVisibleSharedTasks(+ tasks: readonly SharedTaskListItem[],+ ownerAccountId: string | null,+ link: Pick<ReturnType<typeof useDeviceLink>, 'openLink' | 'invoke'>,+ isCurrent: () => boolean,+) {+ const deviceId = (task: SharedTaskListItem) => task.ownerAccountId === ownerAccountId+ ? task.hostDeviceId : sharedTaskHostPeer(task.sharedTaskId, task.hostDeviceId);+ return filterCindyMakeSharedTasks(tasks, {+ isCurrent,+ knownSession: task => remoteSessionStore.getSessions().find(session =>+ session.id === task.sessionId && session.deviceLinkDeviceId === deviceId(task)),+ readSession: async task => {+ const peer = deviceId(task);+ if (task.ownerAccountId !== ownerAccountId) {+ await link.openLink(peer);+ if (!isCurrent()) return null;+ }+ return link.invoke<RemoteSession | null>(peer, 'local-db:sessions:get', [task.sessionId]);+ },+ });+}diff --git a/apps/mobile/src/device-link/useSharedTasks.ts b/apps/mobile/src/device-link/useSharedTasks.tsindex c01375bf24..58187463ec 100644--- a/apps/mobile/src/device-link/useSharedTasks.ts+++ b/apps/mobile/src/device-link/useSharedTasks.ts@@ -6,6 +6,7 @@ import { remoteSessionStore } from '@/session/remoteSessionStore';import type { RemoteSession } from '@/session/types';import { useDeviceLink } from './DeviceLinkContext';import { useSharedTaskApi } from './useSharedTaskApi';+import { filterVisibleSharedTasks } from './sharedTaskVisibility';/** Shared tasks have their own account authority list, separate from paired devices. */export function useSharedTasks(): readonly SharedTaskListItem[] {@@ -25,9 +26,11 @@ export function useSharedTasks(): readonly SharedTaskListItem[] {try {const all = await api.list();if (!current()) return;- // Owner discovery must not depend on full-device remote-control permission.- // Only guests are auto-connected through task-scoped peers.- setOwned({ owner, tasks: all.filter(task => task.ownerAccountId === owner.accountId) });+ const visibleOwned = await filterVisibleSharedTasks(+ all.filter(task => task.ownerAccountId === owner.accountId), owner.accountId, { openLink, invoke }, current,+ );+ if (!current()) return;+ setOwned({ owner, tasks: visibleOwned });const tasks = all.filter(task => task.ownerAccountId !== owner.accountId);const peers = new Set(tasks.map((task) => sharedTaskHostPeer(task.sharedTaskId, task.hostDeviceId)));for (const task of remoteSessionStore.getSessions()) {diff --git a/apps/mobile/src/session/sharedHomeGroup.ts b/apps/mobile/src/session/sharedHomeGroup.tsindex 50ac8d0d46..fc8436291f 100644--- a/apps/mobile/src/session/sharedHomeGroup.ts+++ b/apps/mobile/src/session/sharedHomeGroup.ts@@ -1,4 +1,5 @@import { isSharedTaskPeer, type SharedTaskListItem } from '@cindy/device-link';+import { CINDY_MAKE_ENABLED, isCindyMakeSource } from '@cindy/maker-shared/cindy-make-feature';import type { MobileHomePresentation, MobileHomeSessionLike } from './mobileHome';import type { RemoteSessionListItem } from './sessionList';@@ -9,7 +10,7 @@ export type SharedHomeRow =export type SharedHomeRole = 'owned' | 'joined';/** Group presentation only: routing IDs, store contents and grants stay untouched. */-export function splitSharedHomeGroup(home: MobileHomePresentation, owned: readonly SharedTaskListItem[], options: {+export function splitSharedHomeGroup(home: MobileHomePresentation, owned: readonly (SharedTaskListItem & { source?: string | null })[], options: {sessions: readonly MobileHomeSessionLike[];searchQuery: string;statusFilter: string;@@ -31,6 +32,7 @@ export function splitSharedHomeGroup(home: MobileHomePresentation, owned: readon// Discovery is account-level even before same-account remote control is allowed.// Don't recreate a row that the active search/status filter intentionally hid.for (const task of owned) {+ if (!CINDY_MAKE_ENABLED && (task.source === undefined || isCindyMakeSource(task.source))) continue;if (options.sessions.some(session => owns(session, task))) continue;if (home.selectedDeviceId && home.selectedDeviceId !== task.hostDeviceId) continue;if (options.statusFilter !== 'active' && options.statusFilter !== 'all') continue;diff --git a/docs/product-rules/shared-task-mode.md b/docs/product-rules/shared-task-mode.mdindex f9f37e5fe5..b7994021c2 100644--- a/docs/product-rules/shared-task-mode.md+++ b/docs/product-rules/shared-task-mode.md@@ -52,7 +52,7 @@- 房主使用自己的邀请不走访客加入流程,不创建访客或占用加入名额;服务端返回 HTTP 409 / `SHARED_TASK_SELF_JOIN`,两端提示“这是你发起的共享任务,无需加入。请从‘我发起的’打开”。同账号访问继续使用既有设备互联。旧服务端的通用 `CONFLICT` 仍显示兜底提示,不根据错误消息猜测是否为房主;旧客户端收到新错误码也沿用兜底提示。准确提示需服务端与客户端均升级,接口与成功响应结构不变。- 移除或退出立即撤权;原邀请不可重入,房主生成新邀请后才能再次加入。- 停止共享、归档、房主登出使旧邀请和成员关系失效。重新共享产生新的共享 ID。-- Cindy Make 停用时,房主 Desktop 按本机原始任务来源关闭已有的制作任务共享(含 `cindy-make-merge`),不恢复访客访问、不允许重新开启。复用原有关闭账本与服务端关闭接口,离线先撤销本机授权,联网后重试关闭并从房主、访客目录移除,旧邀请随共享关闭失效;普通任务共享不受影响,任务历史与工作目录保留。实现与回归见 `sharedTaskHost.ts`、`sharedTaskHost.test.ts` 和 `sharedTaskRuntime.test.ts`。+- Cindy Make 停用时,房主 Desktop 按本机原始任务来源关闭已有的制作任务共享(含 `cindy-make-merge`),不恢复访客访问、不允许重新开启。复用原有关闭账本与服务端关闭接口,离线先撤销本机授权,联网后重试关闭并从房主、访客目录移除,旧邀请随共享关闭失效;普通任务共享不受影响,任务历史与工作目录保留。新版控制端的账号共享目录也先按原始元数据确认任务来源;房主离线、旧版或读取失败而无法确认时,不展示标题、管理入口或合成首页行,确认普通来源后恢复显示。来源确认复用现有授权和元数据读取,不为目录发现申请整机远控或扩大访客权限。实现与回归见 `sharedTaskHost.ts`、`sharedTaskHost.test.ts` 和 `sharedTaskRuntime.test.ts`。- 归档后恢复为活动任务,可以显式重新开启共享;须先完成旧共享关闭,旧代次的请求仍然失效。- 房主设备的 relay 连接确认离线后有 60 秒重连宽限,期间重连保留共享、邀请与成员关系;持续离线超过宽限后由下一轮服务端扫描关闭(正常情况下确认离线后 60–90 秒)。关闭后重新上线不会恢复旧共享,需显式重新开启并发送新邀请。主动关闭与登出的显式关闭请求不等待宽限。已由新连接接管的旧连接退出不算离线;TTL 内短暂网络抖动不承诺立即判定。- 服务端是成员关系权威;主机保存恢复与关闭记录。迟到响应、旧快照、缓存和重连不能恢复已撤销访问。diff --git a/packages/maker-shared/src/__tests__/cindyMakeSharedTasks.test.ts b/packages/maker-shared/src/__tests__/cindyMakeSharedTasks.test.tsnew file mode 100644index 0000000000..f29c808a35--- /dev/null+++ b/packages/maker-shared/src/__tests__/cindyMakeSharedTasks.test.ts@@ -0,0 +1,59 @@+import { expect, it, vi } from 'vitest';+import { filterCindyMakeSharedTasks } from '../cindyMakeFeature';++const task = { sessionId: 'task', hostDeviceId: 'offline-host', title: 'Share' };+const options = () => ({+ knownSession: vi.fn<() => { id: string; source?: string | null } | undefined>(() => undefined),+ readSession: vi.fn<() => Promise<{ id: string; source?: string } | null>>(async () => null),+ isCurrent: vi.fn(() => true),+});++it.each(['cindy-make', 'cindy-make-merge'])('hides a legacy share confirmed as %s by the old host', async source => {+ const reader = options();+ reader.readSession.mockResolvedValue({ id: task.sessionId, source });+ expect(await filterCindyMakeSharedTasks([task], reader)).toEqual([]);+});++it.each(['cindy-make', 'cindy-make-merge'])('uses the unfiltered cached %s source even with an offline host', async source => {+ const reader = options();+ reader.knownSession.mockReturnValue({ id: task.sessionId, source });+ expect(await filterCindyMakeSharedTasks([task], reader)).toEqual([]);+ expect(reader.readSession).not.toHaveBeenCalled();+});++it.each(['offline', 'missing', 'wrong-task'])('keeps an unconfirmed %s share hidden and retries on recovery', async reason => {+ const reader = options();+ if (reason === 'offline') reader.readSession.mockRejectedValueOnce(new Error('offline'));+ if (reason === 'wrong-task') reader.readSession.mockResolvedValueOnce({ id: 'other-task', source: 'desktop' });+ expect(await filterCindyMakeSharedTasks([task], reader)).toEqual([]);+ reader.readSession.mockResolvedValue({ id: task.sessionId, source: 'desktop' });+ expect(await filterCindyMakeSharedTasks([task], reader)).toEqual([{ ...task, source: 'desktop' }]);+});++it('confirms a matching legacy ordinary task whose successful metadata omits source', async () => {+ const reader = options();+ reader.knownSession.mockReturnValue({ id: task.sessionId });+ reader.readSession.mockResolvedValue({ id: task.sessionId });+ expect(await filterCindyMakeSharedTasks([task], reader)).toEqual([{ ...task, source: null }]);+ expect(reader.readSession).toHaveBeenCalledExactlyOnceWith(task);+});++it('does not publish an old account response or start new reads after invalidation', async () => {+ const reader = options();+ let current = true;+ reader.isCurrent.mockImplementation(() => current);+ reader.readSession.mockImplementation(async () => { current = false; return { id: task.sessionId, source: 'desktop' }; });+ expect(await filterCindyMakeSharedTasks([task], reader)).toEqual([]);+ reader.readSession.mockClear();+ expect(await filterCindyMakeSharedTasks([task], reader)).toEqual([]);+ expect(reader.readSession).not.toHaveBeenCalled();+});++it('does not let a delayed read override newly arrived hidden source metadata', async () => {+ const reader = options();+ reader.readSession.mockImplementation(async () => {+ reader.knownSession.mockReturnValue({ id: task.sessionId, source: 'cindy-make' });+ return { id: task.sessionId, source: 'desktop' };+ });+ expect(await filterCindyMakeSharedTasks([task], reader)).toEqual([]);+});diff --git a/packages/maker-shared/src/cindyMakeFeature.ts b/packages/maker-shared/src/cindyMakeFeature.tsindex 19f648a156..05983a3e02 100644--- a/packages/maker-shared/src/cindyMakeFeature.ts+++ b/packages/maker-shared/src/cindyMakeFeature.ts@@ -11,3 +11,36 @@ export const CINDY_MAKE_ENABLED = false;export function isCindyMakeSource(source: string | null | undefined): boolean {return source === 'cindy-make' || source === 'cindy-make-merge';}++export type SourceConfirmedSharedTask<Task> = Task & { source: string | null };++type SharedTaskSessionSource = { id: string; source?: string | null };++export async function filterCindyMakeSharedTasks<Task extends { sessionId: string }>(+ tasks: readonly Task[],+ options: {+ knownSession(task: Task): SharedTaskSessionSource | null | undefined;+ readSession(task: Task): Promise<SharedTaskSessionSource | null | undefined>;+ isCurrent(): boolean;+ },+): Promise<SourceConfirmedSharedTask<Task>[]> {+ const confirmed = await Promise.all(tasks.map(async (task): Promise<{ task: Task; source: string | null } | null> => {+ if (!options.isCurrent()) return null;+ const known = options.knownSession(task);+ if (CINDY_MAKE_ENABLED) return { task, source: known?.source ?? null };+ if (known?.id === task.sessionId && known.source !== undefined) {+ return isCindyMakeSource(known.source) ? null : { task, source: known.source };+ }+ try {+ const session = await options.readSession(task);+ if (!options.isCurrent() || session?.id !== task.sessionId) return null;+ const latest = options.knownSession(task);+ const source = latest?.id === task.sessionId && latest.source !== undefined+ ? latest.source : session.source ?? null;+ return isCindyMakeSource(source) ? null : { task, source };+ } catch {+ return null;+ }+ }));+ return options.isCurrent() ? confirmed.flatMap(result => result ? [{ ...result.task, source: result.source }] : []) : [];+}