Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(review): keep reviewer tasks internal
Chris2389963c0de2
diff --git a/apps/desktop/src/main/__tests__/setSessionsStatusInDb.test.ts b/apps/desktop/src/main/__tests__/setSessionsStatusInDb.test.tsindex 2501763ee5..6f671adeef 100644--- a/apps/desktop/src/main/__tests__/setSessionsStatusInDb.test.ts+++ b/apps/desktop/src/main/__tests__/setSessionsStatusInDb.test.ts@@ -15,27 +15,39 @@ import type { SessionRouteLock } from '../localDb/sessionRouteLock.js';type SessionRouteLockMock = SessionRouteLock &MockInstance<(sessionId: string, task: () => Promise<unknown>) => Promise<unknown>>;-const h = vi.hoisted(() => ({- tx: vi.fn(),- tapWindowBroadcast: vi.fn(),- webContentsSend: vi.fn(),- closeSession: vi.fn(),- isSessionAlive: vi.fn(),- withSendToSessionLock: vi.fn(async <T>(_sessionId: string, task: () => Promise<T>): Promise<T> =>- task(),- ) as SessionRouteLockMock,- isSessionStillRemovable: vi.fn(),- cancelSessionOperations: vi.fn(),- cleanupRemovedSession: vi.fn(),- removeSessionRefs: vi.fn(),- recycleWorktreeForRemovedSession: vi.fn(),- isOwnerScopeCurrent: vi.fn(),- drizzle: {},- userDataPath: '',- agentIslandService: {- handleSessionMetadataPatch: vi.fn(),- },-}));+const h = vi.hoisted(() => {+ const reviewSource = { current: 'desktop' };+ const drizzle = {+ select: vi.fn(() => {+ const chain: Record<string, unknown> = {};+ chain.from = () => chain;+ chain.where = () => Promise.resolve([{ source: reviewSource.current }]);+ return chain;+ }),+ };+ return {+ tx: vi.fn(),+ tapWindowBroadcast: vi.fn(),+ webContentsSend: vi.fn(),+ closeSession: vi.fn(),+ isSessionAlive: vi.fn(),+ withSendToSessionLock: vi.fn(+ async <T>(_sessionId: string, task: () => Promise<T>): Promise<T> => task(),+ ) as SessionRouteLockMock,+ isSessionStillRemovable: vi.fn(),+ cancelSessionOperations: vi.fn(),+ cleanupRemovedSession: vi.fn(),+ removeSessionRefs: vi.fn(),+ recycleWorktreeForRemovedSession: vi.fn(),+ isOwnerScopeCurrent: vi.fn(),+ drizzle,+ reviewSource,+ userDataPath: '',+ agentIslandService: {+ handleSessionMetadataPatch: vi.fn(),+ },+ };+});vi.mock('electron', () => ({app: { getPath: () => h.userDataPath },@@ -95,6 +107,7 @@ beforeEach(() => {h.removeSessionRefs.mockResolvedValue(0);h.recycleWorktreeForRemovedSession.mockResolvedValue(undefined);h.isOwnerScopeCurrent.mockReturnValue(true);+ h.reviewSource.current = 'desktop';setSessionRemovalCancelOperations(h.cancelSessionOperations);setSessionRemovalCleanup(h.cleanupRemovedSession);setSessionRouteLockImplementation(h.withSendToSessionLock);@@ -163,6 +176,17 @@ describe('setSessionsStatusInDb', () => {expect(h.tx).not.toHaveBeenCalled();});+ it('rejects batch lifecycle changes for retained Review audit details', async () => {+ h.reviewSource.current = 'review';++ await expect(setSessionsStatusInDb(['review-1'], 'archived')).rejects.toThrow(+ /Review audit details are read-only/,+ );++ expect(h.tx).not.toHaveBeenCalled();+ expect(h.withSendToSessionLock).not.toHaveBeenCalled();+ });+it('does not schedule recycle when batch restores sessions to active', async () => {h.tx.mockResolvedValueOnce([{diff --git a/apps/desktop/src/main/localDb/ipc/__tests__/sessionsRestoreIfArchived.test.ts b/apps/desktop/src/main/localDb/ipc/__tests__/sessionsRestoreIfArchived.test.tsindex 514117df28..5e6177ec2a 100644--- a/apps/desktop/src/main/localDb/ipc/__tests__/sessionsRestoreIfArchived.test.ts+++ b/apps/desktop/src/main/localDb/ipc/__tests__/sessionsRestoreIfArchived.test.ts@@ -224,4 +224,12 @@ describe('local-db:sessions:restore-if-archived', () => {it('throws NOT_FOUND when the session no longer exists', async () => {await expect(restore('missing')).rejects.toThrow('[NOT_FOUND]');});++ it('rejects restoring a retained Review audit detail', async () => {+ h.sqlite!.prepare("UPDATE sessions SET source = 'review' WHERE id = 'target'").run();++ await expect(restore()).rejects.toThrow(/Review audit details are read-only/);+ expect(readStatus()).toBe('archived');+ expect(h.routeLock).not.toHaveBeenCalled();+ });});diff --git a/apps/desktop/src/main/localDb/ipc/__tests__/sessionsUpdate.test.ts b/apps/desktop/src/main/localDb/ipc/__tests__/sessionsUpdate.test.tsindex 18119b36e9..13e3e502d6 100644--- a/apps/desktop/src/main/localDb/ipc/__tests__/sessionsUpdate.test.ts+++ b/apps/desktop/src/main/localDb/ipc/__tests__/sessionsUpdate.test.ts@@ -182,16 +182,30 @@ describe('local-db:sessions:update handler wiring', () => {expect(h.routeLock).toHaveBeenCalledWith('codex-local', expect.any(Function));});- it('rejects setting drift for retained Review tasks while preserving metadata edits', async () => {- await expect(invokeUpdate('review-local', { effort: 'low' })).rejects.toThrow(- /Review task settings are fixed/,+ it.each([+ ['settings', { effort: 'low' }],+ ['title', { title: '审查记录' }],+ ['pin', { pinnedAt: '2026-08-13T00:00:00.000Z' }],+ ['lifecycle', { status: 'archived' }],+ ])('rejects forged %s mutations for retained Review audit details', async (_kind, patch) => {+ await expect(invokeUpdate('review-local', patch)).rejects.toThrow(+ /Review audit details are read-only/,);- await invokeUpdate('review-local', { title: '审查记录' });const persisted = h- .sqlite!.prepare('SELECT effort, title FROM sessions WHERE id = ?')- .get('review-local') as { effort: string; title: string };- expect(persisted).toEqual({ effort: 'high', title: '审查记录' });+ .sqlite!.prepare('SELECT effort, title, pinned_at, status FROM sessions WHERE id = ?')+ .get('review-local') as {+ effort: string;+ title: string;+ pinned_at: number | null;+ status: string;+ };+ expect(persisted).toEqual({+ effort: 'high',+ title: 'New CCS',+ pinned_at: null,+ status: 'active',+ });});it('persists and broadcasts title-only patches to device-link subscribers', async () => {diff --git a/apps/desktop/src/main/localDb/ipc/sessions.ts b/apps/desktop/src/main/localDb/ipc/sessions.tsindex 3fbb72a9d5..0f40e47d33 100644--- a/apps/desktop/src/main/localDb/ipc/sessions.ts+++ b/apps/desktop/src/main/localDb/ipc/sessions.ts@@ -56,6 +56,7 @@ import { removeTurnChangeSetsForSession } from '../../turn-change-set/store.js';import { quiesceSessionBeforeWorktreeRecycle } from './sessionRemovalOperations.js';import { withSessionRouteLock, withSessionRouteLocks } from '../sessionRouteLock.js';import { broadcastSubagentRunsInvalidated } from './subagentRuns.js';+import { assertReviewSessionMutationAllowed } from '../../reviewer/reviewSessionMutationPolicy.js';const log = createLogger('sessions');const REMOTE_EDITABLE_META = new Set(['status', 'title', 'pinnedAt']);@@ -1287,6 +1288,7 @@ export function registerSessionIpc(}const db = getDbClient().drizzle;+ await assertReviewSessionMutationAllowed(sid);const updated = await withSessionRouteLock(sid, async () => {if (!isOwnerScopeCurrent(ownerScope)) return null;// 显式 .run() 才能从生产 DbClient.drizzle proxy 拿到 changes;隐式 await@@ -1360,31 +1362,7 @@ export function registerSessionIpc(if (typeof p.workingDir === 'string') {p.workingDir = normalizeWorkingDirForStorage(p.workingDir) ?? null;}- const REVIEW_IMMUTABLE_FIELDS = new Set([- 'workingDir',- 'workspaceKind',- 'model',- 'providerId',- 'effort',- 'permissionMode',- 'fastMode',- 'planModeEnabled',- 'orcaRole',- 'extraDirs',- ]);- if (Object.keys(p).some((key) => REVIEW_IMMUTABLE_FIELDS.has(key))) {- const [target] = await db- .select({ source: sessions.source })- .from(sessions)- .where(eq(sessions.id, sid))- .limit(1);- if (target?.source === 'review') {- throwIpcError(- 'UNSUPPORTED_CAPABILITY',- 'Review task settings are fixed to the source task',- );- }- }+ if (Object.keys(p).length > 0) await assertReviewSessionMutationAllowed(sid);// 会话移动转录迁移:patch 带 workingDir 时先留存旧值,update 后对比实际变化。// CLI 转录按 cwd 转码目录存放,workingDir 变了必须跟着搬,否则 resume 报// "No conversation found with session ID"(见 claude-transcript-relocation.ts)。@@ -1575,6 +1553,7 @@ export async function patchSessionMetaInDb(}const db = getDbClient().drizzle;+ await assertReviewSessionMutationAllowed(sessionId);const setObj = sessionPatchToRow(patch, { bumpUpdatedAt: false });// 控制端远程改名走这条,与本机改名同口径(同样先记号后写库)。if (patch.title !== undefined) noteUserTitleWritten(sessionId);@@ -1676,6 +1655,10 @@ export async function renameSessionTitlesInDb(if (dryRun) return preview;+ for (const change of changes) {+ await assertReviewSessionMutationAllowed(change.sessionId);+ }+// 批量改名(MCP 工具)同样是"人给的名字",自动起名不得再覆盖;与上面两条出口// 一样先记号后写库,不给并发的智能标题留窗口。for (const change of changes) noteUserTitleWritten(change.sessionId);@@ -1725,6 +1708,9 @@ export async function setSessionsStatusInDb(if (sessionIds.length === 0) return [];const ownerScope = captureOwnerScope();const dbClient = getDbClient();+ for (const sessionId of sessionIds) {+ await assertReviewSessionMutationAllowed(sessionId);+ }const applied = await withSessionRouteLocks(sessionIds, () =>dbClient.tx('sessions.setStatus', { sessionIds, status }).catch((err) => {const code = (err as { code?: string }).code;diff --git a/apps/desktop/src/main/maker-ipc/__tests__/messageDeleteHandler.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/messageDeleteHandler.test.tsindex 51cc110a19..082d2b9151 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/messageDeleteHandler.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/messageDeleteHandler.test.ts@@ -11,7 +11,7 @@ function makeDeps(overrides: Partial<MessageDeleteHandlerDeps> = {},): MessageDeleteHandlerDeps {return {- getSessionRow: vi.fn(async () => ({ status: 'active', agentKind: 'cc' })),+ getSessionRow: vi.fn(async () => ({ status: 'active', agentKind: 'cc', source: 'desktop' })),getMessage: vi.fn(async () => ({id: 'target-row',role: 'user' as const,@@ -42,6 +42,24 @@ function makeDeps(}describe('performMessageDeletion', () => {+ it('rejects forged deletion requests for Review audit details before any side effect', async () => {+ const deps = makeDeps({+ getSessionRow: vi.fn(async () => ({+ status: 'active',+ agentKind: 'codex',+ source: 'review',+ })),+ });++ await expect(+ performMessageDeletion(deps, { sessionId: 'review-1', clientId: 'target' }),+ ).rejects.toThrow(/Review audit details are read-only/);++ expect(deps.closeSession).not.toHaveBeenCalled();+ expect(deps.drainPersistQueue).not.toHaveBeenCalled();+ expect(deps.commitDeletion).not.toHaveBeenCalled();+ });+it('keeps the deleted-session preview on the visible message projection', () => {const source = readFileSync(resolve(process.cwd(), 'src/main/localDb/ipc/messages.ts'), 'utf8');const deletionBlock = source.slice(diff --git a/apps/desktop/src/main/maker-ipc/__tests__/reviewStartHandler.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/reviewStartHandler.test.tsindex e95352a32e..c339a8287b 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/reviewStartHandler.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/reviewStartHandler.test.ts@@ -101,7 +101,6 @@ function makeDeps(publishReviewerLink: vi.fn(async () => undefined),startReviewer: vi.fn(async () => reviewer),markReviewerStarted: vi.fn(async () => undefined),- broadcastReviewerCreated: vi.fn(),persistReviewerPrompt: vi.fn(async () => undefined),drainPersistQueue: vi.fn(async () => undefined),readReviewerResult: vi.fn(async () => 'P1: real finding'),@@ -497,11 +496,11 @@ describe('maker:review:start IPC lifecycle', () => {);});- it('installs the close listener before publishing the reviewer task', async () => {+ it('installs the close listener before exposing the internal reviewer link', async () => {const harness = new IpcHarness();const reviewer = new FakeReviewer();const deps = makeDeps(reviewer);- vi.mocked(deps.broadcastReviewerCreated).mockImplementationOnce(() => {+ vi.mocked(deps.markReviewerStarted).mockImplementationOnce(async () => {reviewer.emitStatus('closed');});registerReviewStartHandler(harness, deps);@@ -510,6 +509,7 @@ describe('maker:review:start IPC lifecycle', () => {code: 'PRECONDITION_FAILED',});expect(reviewer.send).not.toHaveBeenCalled();+ expect(deps.publishReviewerLink).not.toHaveBeenCalled();await expect(harness.invoke(MAKER_INVOKE.START_REVIEW, reviewRequest())).resolves.toMatchObject({diff --git a/apps/desktop/src/main/maker-ipc/__tests__/rewind-ipc.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/rewind-ipc.test.tsindex 248b53ac29..139552136c 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/rewind-ipc.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/rewind-ipc.test.ts@@ -12,6 +12,7 @@ const mocks = vi.hoisted(() => ({finishSubagentRewindFence: vi.fn(),primeSubagentRewindFence: vi.fn(),listVisibleSubagentObservationIdentities: vi.fn(),+ assertSessionMutationAllowed: vi.fn(),}));vi.mock('electron', () => ({@@ -81,7 +82,24 @@ describe('maker rewind IPC stop-then-rewind', () => {token: Symbol('rewind'),});mocks.listVisibleSubagentObservationIdentities.mockResolvedValue([]);- registerMakerRewindIpc();+ mocks.assertSessionMutationAllowed.mockResolvedValue(undefined);+ registerMakerRewindIpc({+ assertSessionMutationAllowed: mocks.assertSessionMutationAllowed,+ });+ });++ it('rejects forged Review rewind requests before opening a mutation fence', async () => {+ mocks.assertSessionMutationAllowed.mockRejectedValueOnce(+ new Error('[UNSUPPORTED_CAPABILITY] Review audit details are read-only'),+ );+ const handler = mocks.handlers.get(MAKER_INVOKE.REWIND_COMMIT);+ if (!handler) throw new Error('rewind commit handler not registered');++ await expect(handler({}, 'review-1', 'message-1')).rejects.toThrow(+ /Review audit details are read-only/,+ );+ expect(mocks.beginSubagentRewindFence).not.toHaveBeenCalled();+ expect(mocks.commitRewindAtMessage).not.toHaveBeenCalled();});it('runs normal rewind inside the stopped input boundary when requested', async () => {diff --git a/apps/desktop/src/main/maker-ipc/messageDeleteHandler.ts b/apps/desktop/src/main/maker-ipc/messageDeleteHandler.tsindex 2f4d6812c1..7777d780b7 100644--- a/apps/desktop/src/main/maker-ipc/messageDeleteHandler.ts+++ b/apps/desktop/src/main/maker-ipc/messageDeleteHandler.ts@@ -24,6 +24,7 @@ interface ContextSourceMessage extends HandoffSourceMessage {interface MessageDeleteSessionRow {status: string;agentKind: string;+ source: string;}/**@@ -94,6 +95,9 @@ export async function performMessageDeletion(if (!sessionRow || sessionRow.status === 'deleted') {throwIpcError('NOT_FOUND', `Session ${sessionId} not found`);}+ if (sessionRow.source === 'review') {+ throwIpcError('UNSUPPORTED_CAPABILITY', 'Review audit details are read-only');+ }if (!initialTarget) {throwIpcError('NOT_FOUND', 'Message 不存在或不可删除');}diff --git a/apps/desktop/src/main/maker-ipc/register.ts b/apps/desktop/src/main/maker-ipc/register.tsindex 441f00a856..c610c6ac6a 100644--- a/apps/desktop/src/main/maker-ipc/register.ts+++ b/apps/desktop/src/main/maker-ipc/register.ts@@ -7396,7 +7396,6 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions).set({ userSendAt: startedAt, updatedAt: startedAt }).where(eq(sessions.id, reviewerSessionId));},- broadcastReviewerCreated: broadcastSessionCreated,persistReviewerPrompt: async ({ reviewerSessionId, runId, prompt, sourceAgentKind }) => {await createDbMessage(reviewerSessionId, {clientId: `review-prompt:${runId}`,@@ -7597,7 +7596,11 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)registerMakerMessageDeleteHandler(makerSessionRegistry, {getSessionRow: async (sessionId) => {const [row] = await getDbClient()- .drizzle.select({ status: sessions.status, agentKind: sessions.agentKind })+ .drizzle.select({+ status: sessions.status,+ agentKind: sessions.agentKind,+ source: sessions.source,+ }).from(sessions).where(eq(sessions.id, sessionId)).limit(1);diff --git a/apps/desktop/src/main/maker-ipc/reviewStartHandler.ts b/apps/desktop/src/main/maker-ipc/reviewStartHandler.tsindex cebbf72061..29771f091f 100644--- a/apps/desktop/src/main/maker-ipc/reviewStartHandler.ts+++ b/apps/desktop/src/main/maker-ipc/reviewStartHandler.ts@@ -198,7 +198,6 @@ export interface ReviewStartHandlerDeps {publishReviewerLink(input: ReviewCardWrite): Promise<void>;startReviewer(createOpts: MakerSessionCreateOpts): Promise<ReviewRunnerHandle>;markReviewerStarted(reviewerSessionId: string, startedAt: number): Promise<void>;- broadcastReviewerCreated(reviewerSessionId: string): void;persistReviewerPrompt(input: {reviewerSessionId: string;runId: string;@@ -548,20 +547,17 @@ export function registerReviewStartHandler(void terminalFinalization;});- // Install both terminal listeners before the reviewer becomes visible to- // the renderer. Otherwise an immediate user close can land between the- // created broadcast and listener registration, leaving the source gate- // permanently occupied.+ // Install both terminal listeners before the source card exposes the+ // internal reviewer link. Otherwise an immediate close can land between+ // link publication and listener registration, leaving the source gate+ // permanently occupied. Reviewer sessions intentionally do not emit the+ // ordinary session-created broadcast: they are audit details owned by+ // the source card, not peers in the normal task sidebar.await deps.markReviewerStarted(reviewerSessionId, startedAt);if (settled) {await terminalFinalization;throwIpcError('PRECONDITION_FAILED', 'Reviewer task closed before it started');}- deps.broadcastReviewerCreated(reviewerSessionId);- if (settled) {- await terminalFinalization;- throwIpcError('PRECONDITION_FAILED', 'Reviewer task closed before it started');- }await enqueueSourceCardWrite(() =>deps.publishReviewerLink({sourceSessionId: request.sourceSessionId,diff --git a/apps/desktop/src/main/maker-ipc/rewind.ts b/apps/desktop/src/main/maker-ipc/rewind.tsindex 50ee7698e2..5263467ce3 100644--- a/apps/desktop/src/main/maker-ipc/rewind.ts+++ b/apps/desktop/src/main/maker-ipc/rewind.ts@@ -32,6 +32,7 @@ import { requireString, throwIpcError } from '../utils/ipcValidate.js';import { MAKER_INVOKE } from './channels.js';import { withSessionInputStoppedForRewind } from './register.js';import { agentHandoffPending } from './agentHandoffPendingSingleton.js';+import { assertReviewSessionMutationAllowed } from '../reviewer/reviewSessionMutationPolicy.js';const log = createLogger('maker-ipc/rewind');const STOPPED_REWIND_RETRY_MS = 100;@@ -75,7 +76,15 @@ function wrapErr(err: unknown): never {throwIpcError(code, msg);}-export function registerMakerRewindIpc(): void {+export interface MakerRewindIpcDeps {+ assertSessionMutationAllowed(sessionId: string): Promise<void>;+}++export function registerMakerRewindIpc(+ deps: MakerRewindIpcDeps = {+ assertSessionMutationAllowed: assertReviewSessionMutationAllowed,+ },+): void {ipcMain.handle(MAKER_INVOKE.REWIND_PREVIEW,async (@@ -86,6 +95,7 @@ export function registerMakerRewindIpc(): void {const sid = requireString(sessionId, 'sessionId');const cid = requireString(clientId, 'clientId');try {+ await deps.assertSessionMutationAllowed(sid);return await previewRewindAtMessage(sid, cid);} catch (err) {log.warn('rewind:preview failed', { sid, cid, error: String(err) });@@ -120,6 +130,7 @@ export function registerMakerRewindIpc(): void {let fenceCommitted = false;let visibleSubagentIdentitiesAfterCommit: VisibleSubagentObservationIdentity[] = [];try {+ await deps.assertSessionMutationAllowed(sid);subagentFence = beginSubagentRewindFence(sid);primeSubagentRewindFence(subagentFence,diff --git a/apps/desktop/src/main/reviewer/reviewSessionMutationPolicy.ts b/apps/desktop/src/main/reviewer/reviewSessionMutationPolicy.tsnew file mode 100644index 0000000000..cf8604c2af--- /dev/null+++ b/apps/desktop/src/main/reviewer/reviewSessionMutationPolicy.ts@@ -0,0 +1,20 @@+import { eq } from 'drizzle-orm';++import { getDbClient } from '../localDb/client/current.js';+import { sessions } from '../localDb/schema.js';+import { throwIpcError } from '../utils/ipcValidate.js';++/**+ * Review tasks are durable audit details owned by their source card. Renderer+ * controls are only a convenience boundary; every mutating IPC must also fail+ * closed against the persisted source so a forged/stale request cannot alter+ * the record.+ */+export async function assertReviewSessionMutationAllowed(sessionId: string): Promise<void> {+ const [row] = await getDbClient()+ .drizzle.select({ source: sessions.source })+ .from(sessions)+ .where(eq(sessions.id, sessionId));+ if (row?.source !== 'review') return;+ throwIpcError('UNSUPPORTED_CAPABILITY', 'Review audit details are read-only');+}diff --git a/apps/desktop/src/renderer/__tests__/automationGeneratedSessions.test.ts b/apps/desktop/src/renderer/__tests__/automationGeneratedSessions.test.tsindex 475e867da0..073e54ba1b 100644--- a/apps/desktop/src/renderer/__tests__/automationGeneratedSessions.test.ts+++ b/apps/desktop/src/renderer/__tests__/automationGeneratedSessions.test.ts@@ -115,7 +115,6 @@ describe('automation-generated sessions', () => {'wecom','scheduler','learn',- 'review','shared','plugin',]);@@ -123,7 +122,9 @@ describe('automation-generated sessions', () => {expect(DESKTOP_VISIBLE_SESSION_SOURCES).toContain('telegram');expect(DESKTOP_VISIBLE_SESSION_SOURCES).toContain('discord');expect(DESKTOP_VISIBLE_SESSION_SOURCES).toContain('dingtalk');- expect(DESKTOP_VISIBLE_SESSION_SOURCES).toContain('review');+ // Reviewers are internal audit tasks reachable from their source cards;+ // they must not compete with ordinary tasks in the sidebar.+ expect(DESKTOP_VISIBLE_SESSION_SOURCES).not.toContain('review');expect(DESKTOP_VISIBLE_SESSION_SOURCES).toContain('plugin');expect(normalizeSessionSource('desktop')).toBe('desktop');@@ -134,6 +135,7 @@ describe('automation-generated sessions', () => {expect(normalizeSessionSource('discord')).toBe('discord');expect(normalizeSessionSource('dingtalk')).toBe('dingtalk');expect(normalizeSessionSource('wecom')).toBe('wecom');+ expect(normalizeSessionSource('review')).toBe('review');expect(normalizeSessionSource('plugin')).toBe('plugin');expect(normalizeSessionSource(null)).toBe('desktop');expect(normalizeSessionSource('unknown')).toBe('desktop');diff --git a/apps/desktop/src/renderer/__tests__/sessionContentHeaderDragRegion.test.ts b/apps/desktop/src/renderer/__tests__/sessionContentHeaderDragRegion.test.tsindex a14da1441d..b85092b751 100644--- a/apps/desktop/src/renderer/__tests__/sessionContentHeaderDragRegion.test.ts+++ b/apps/desktop/src/renderer/__tests__/sessionContentHeaderDragRegion.test.ts@@ -30,7 +30,7 @@ describe('SessionContentHeader window drag region', () => {// 标题 span 留在 drag region 会让 onDoubleClick 被窗口拖拽区吞掉,// 双击改名整体失效(d7dc967df 回归)。expect(sessionHeaderSource).toMatch(- /onDoubleClick=\{startEdit\}[\s\S]{0,240}style=\{WINDOW_NO_DRAG_STYLE\}/,+ /onDoubleClick=\{auditReadOnly \? undefined : startEdit\}[\s\S]{0,240}style=\{WINDOW_NO_DRAG_STYLE\}/,);});@@ -38,7 +38,7 @@ describe('SessionContentHeader window drag region', () => {// no-drag 之后拖窗习惯必须用 useManualWindowDrag 补回:按住标题移动// 依旧拖动窗口,双击仍进改名(两者缺一都是回归)。expect(sessionHeaderSource).toMatch(- /\{\.\.\.titleManualDrag\}[\s\S]{0,80}onDoubleClick=\{startEdit\}/,+ /\{\.\.\.titleManualDrag\}[\s\S]{0,120}onDoubleClick=\{auditReadOnly \? undefined : startEdit\}/,);expect(sessionHeaderSource).toContain('const titleManualDrag = useManualWindowDrag();',diff --git a/apps/desktop/src/renderer/__tests__/systemCardReview.test.tsx b/apps/desktop/src/renderer/__tests__/systemCardReview.test.tsxindex 84ae503076..a5b18736d8 100644--- a/apps/desktop/src/renderer/__tests__/systemCardReview.test.tsx+++ b/apps/desktop/src/renderer/__tests__/systemCardReview.test.tsx@@ -49,7 +49,7 @@ describe('SystemCard Review', () => {expect(screen.getByText('chat.systemCard.review.readOnlyHint')).toBeTruthy();});- it('renders the completed findings and opens the isolated reviewer task', () => {+ it('renders the completed findings and opens the internal review details', () => {renderCard({status: 'completed',reviewerSessionId: 'review-task',diff --git a/apps/desktop/src/renderer/components/chat/AssistantMessage.tsx b/apps/desktop/src/renderer/components/chat/AssistantMessage.tsxindex 1f8775b962..a6efa82380 100644--- a/apps/desktop/src/renderer/components/chat/AssistantMessage.tsx+++ b/apps/desktop/src/renderer/components/chat/AssistantMessage.tsx@@ -171,6 +171,8 @@ interface AssistantMessageProps {/** Owning session's remote SSH host id (null for local). Remote cc daemon* sessions don't support the query-rebuild that Fork needs yet (MVP). */remoteHostId?: string | null;+ /** Hide every action that can mutate or branch from an audit-only message. */+ readOnly?: boolean;/** True when this assistant belongs to the still-active tail turn. */forkBlocked?: boolean;/** Whole-session running state; single-message deletion waits until idle. */@@ -210,6 +212,7 @@ export const AssistantMessage = memo(function AssistantMessage({messageClientId,agentKind,remoteHostId,+ readOnly = false,forkBlocked,sessionRunning,showActionBar = false,@@ -390,10 +393,12 @@ export const AssistantMessage = memo(function AssistantMessage({copyLinkText={messageDeepLink}align="left"hovered={hovered}- onFork={canFork ? handleFork : undefined}- onAddToChat={messageDeepLink ? handleAddToChat : undefined}+ onFork={!readOnly && canFork ? handleFork : undefined}+ onAddToChat={!readOnly && messageDeepLink ? handleAddToChat : undefined}onShareAsImage={handleShareAsImage}- onDelete={currentSessionId && messageClientId ? handleDelete : undefined}+ onDelete={+ !readOnly && currentSessionId && messageClientId ? handleDelete : undefined+ }turnMoney={turnMoney}turnCostUsd={turnCostUsd}turnCostIsEstimate={turnCostIsEstimate}diff --git a/apps/desktop/src/renderer/components/chat/MessageStream.tsx b/apps/desktop/src/renderer/components/chat/MessageStream.tsxindex 2189732c26..eaf9533bc0 100644--- a/apps/desktop/src/renderer/components/chat/MessageStream.tsx+++ b/apps/desktop/src/renderer/components/chat/MessageStream.tsx@@ -239,6 +239,8 @@ interface MessageStreamProps {* so message-level controls can gate features unsupported on remote* (e.g. rewind on cc-remote daemon sessions). */remoteHostId?: string | null;+ /** Review audit details may be inspected and copied, but never mutated. */+ readOnly?: boolean;/** Session working directory; passed down so MarkdownRenderer / UserMessage* can resolve relative paths in markdown links and inline @-chips* (text-lightbox-trigger-extension F1 / F2). Stable within a session@@ -2367,6 +2369,7 @@ function renderWorkGroupChild(sessionTitle?: string | null;agentKind?: 'cc' | 'codex' | 'pi';remoteHostId?: string | null;+ readOnly: boolean;isSessionStreaming: boolean;firstUserMessageClientId: string | null;lastUserMessageClientId: string | null;@@ -2409,6 +2412,7 @@ function renderWorkGroupChild(sessionTitle={props.sessionTitle}agentKind={props.agentKind}remoteHostId={props.remoteHostId}+ readOnly={props.readOnly}sessionRunning={props.isSessionStreaming}assistantForkBlocked={shouldBlockAssistantFork(props.isSessionStreaming,@@ -2521,6 +2525,7 @@ export function MessageStream({sessionTitle,agentKind,remoteHostId,+ readOnly = false,workingDir,messages,taskUpdates,@@ -4404,6 +4409,7 @@ export function MessageStream({sessionTitle,agentKind,remoteHostId,+ readOnly,isSessionStreaming,firstUserMessageClientId,lastUserMessageClientId,@@ -4537,6 +4543,7 @@ export function MessageStream({sessionTitle={sessionTitle}agentKind={agentKind}remoteHostId={remoteHostId}+ readOnly={readOnly}sessionRunning={isSessionStreaming}assistantForkBlocked={shouldBlockAssistantFork(isSessionStreaming,@@ -4636,6 +4643,7 @@ const MessageItem = memo(function MessageItem({sessionTitle,agentKind,remoteHostId,+ readOnly,sessionRunning,assistantForkBlocked,assistantIsTurnFinal,@@ -4658,6 +4666,8 @@ const MessageItem = memo(function MessageItem({/** Owning session's remote SSH host id; forwarded to User/AssistantMessage* to gate Fork/Rewind (unsupported on remote cc daemon sessions). */remoteHostId?: string | null;+ /** Review audit details expose copy/share only, never mutation actions. */+ readOnly: boolean;/** Forwarded to User/AssistantMessage so they can read this agent's* capabilities (gates Fork/Rewind icon visibility). */agentKind?: 'cc' | 'codex' | 'pi';@@ -4735,6 +4745,7 @@ const MessageItem = memo(function MessageItem({sessionId={sessionId}agentKind={agentKind}remoteHostId={remoteHostId}+ readOnly={readOnly}messageClientId={message.clientId}sessionRunning={sessionRunning}isFirstUserMessage={isFirstUserMessage}@@ -4769,6 +4780,7 @@ const MessageItem = memo(function MessageItem({messageClientId={message.clientId}agentKind={agentKind}remoteHostId={remoteHostId}+ readOnly={readOnly}forkBlocked={assistantForkBlocked}sessionRunning={sessionRunning}// 任务执行过程中(尾部 turn 流式中,forkBlocked=true)不出现操作行;diff --git a/apps/desktop/src/renderer/components/chat/UserMessage.tsx b/apps/desktop/src/renderer/components/chat/UserMessage.tsxindex 5f0ba992a5..348d5dc61b 100644--- a/apps/desktop/src/renderer/components/chat/UserMessage.tsx+++ b/apps/desktop/src/renderer/components/chat/UserMessage.tsx@@ -159,6 +159,8 @@ interface UserMessageProps {* sessions don't support the query-rebuild that Fork/Rewind need yet (MVP),* so both actions are hidden when this is set. */remoteHostId?: string | null;+ /** Hide every action that can mutate or branch from an audit-only message. */+ readOnly?: boolean;/** clientId of this message (== messages.client_id in DB). Backend's* fork IPC takes (sessionId, clientId) to locate the fork point. When* omitted, the Fork button is not rendered. */@@ -934,6 +936,7 @@ export function UserMessage({sessionId,agentKind,remoteHostId,+ readOnly = false,messageClientId,sessionRunning,delivery,@@ -1744,12 +1747,18 @@ export function UserMessage({copyLinkText={messageDeepLink}align="right"hovered={hovered}- onFork={!isBlocked && canFork ? handleFork : undefined}- onAddToChat={!isBlocked && messageDeepLink ? handleAddToChat : undefined}+ onFork={!readOnly && !isBlocked && canFork ? handleFork : undefined}+ onAddToChat={+ !readOnly && !isBlocked && messageDeepLink ? handleAddToChat : undefined+ }onShareAsImage={handleShareAsImage}- onDelete={!isBlocked && sessionId && messageClientId ? handleDelete : undefined}- onEdit={canEdit ? handleEdit : undefined}- onRewind={!isBlocked && canRewind ? handleRewind : undefined}+ onDelete={+ !readOnly && !isBlocked && sessionId && messageClientId+ ? handleDelete+ : undefined+ }+ onEdit={!readOnly && canEdit ? handleEdit : undefined}+ onRewind={!readOnly && !isBlocked && canRewind ? handleRewind : undefined}rewindInFlight={rewindOpen}/></>diff --git a/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx b/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsxindex 92f27565ac..de9fb9a083 100644--- a/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx@@ -3680,6 +3680,7 @@ export function CCAgentSessionView({// 消息下方 Fork / Rewind icon 的显示 (Codex rewind=false → 隐藏)。agentKind={session?.agentKind}remoteHostId={session?.remoteHostId ?? null}+ readOnly={session?.source === 'review'}// text-lightbox-trigger-extension F1/F2: cwd flows from session// owner down through MessageStream → AssistantMessage / UserMessage.// The spec guarantees `session.workingDir` is set; `?? ''` is purelydiff --git a/apps/desktop/src/renderer/features/cc-agent/SessionContentHeader.tsx b/apps/desktop/src/renderer/features/cc-agent/SessionContentHeader.tsxindex 4e8b5e5c78..6ebe57cff9 100644--- a/apps/desktop/src/renderer/features/cc-agent/SessionContentHeader.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/SessionContentHeader.tsx@@ -139,6 +139,7 @@ export function SessionContentHeader({// 会停留在旧值(Codex review P2)。prop 兜底覆盖 archived 等不在// active 桶里的会话。const session = routeSessionById.get(sessionProp.id) ?? sessionProp;+ const auditReadOnly = session.source === 'review';const { runningSessionIds } = useSessionRunningStatus(session.id);const { confirm: confirmDialog } = useConfirmDialog();const { runSessionAction, unarchiveSession } = useSessionLifecycleActions();@@ -603,7 +604,7 @@ export function SessionContentHeader({</Tip>)}- {isEditing ? (+ {isEditing && !auditReadOnly ? (<div style={WINDOW_NO_DRAG_STYLE}><SessionRenameInputsessionId={session.id}@@ -627,7 +628,7 @@ export function SessionContentHeader({// 双击(死区内)不动窗、正常进入改名。<span{...titleManualDrag}- onDoubleClick={startEdit}+ onDoubleClick={auditReadOnly ? undefined : startEdit}title={displayTitle}className="min-w-0 max-w-[40vw] cursor-default truncate text-sm font-medium text-foreground"style={WINDOW_NO_DRAG_STYLE}@@ -636,7 +637,7 @@ export function SessionContentHeader({</span>)}- {!isEditing && (+ {!isEditing && !auditReadOnly && (// 菜单打开就把归档/删除的 dirty 预检发出去:用户从展开菜单到点条目至少// 一次反应时间,足够这次 git status 跑完,点下去时命中缓存、零等待。<DropdownMenudiff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.jsonindex a6d8621d7e..23103a0b1c 100644--- a/apps/desktop/src/renderer/i18n/locales/en/common.json+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json@@ -6486,8 +6486,8 @@"running": "Reviewing current work","completed": "Review complete","failed": "Review did not complete",- "openTask": "Open review task",- "readOnlyHint": "Independent task · no development memory · read-only",+ "openTask": "View review details",+ "readOnlyHint": "Internal review · no development memory · read-only","noResult": "The reviewer returned no visible conclusion","failure": {"reviewerClosed": "The review task closed before it finished",diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.jsonindex 4e6f602b02..8b244383fc 100644--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json@@ -6483,8 +6483,8 @@"running": "現在の成果をレビュー中","completed": "レビュー完了","failed": "レビューを完了できませんでした",- "openTask": "レビュータスクを開く",- "readOnlyHint": "独立タスク・開発メモリなし・読み取り専用",+ "openTask": "レビュー詳細を表示",+ "readOnlyHint": "内部レビュー・開発メモリなし・読み取り専用","noResult": "レビュー結果が返されませんでした","failure": {"reviewerClosed": "レビュータスクは完了前に閉じられました",diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.jsonindex 9e41f0d2a0..69d988f265 100644--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json@@ -6483,8 +6483,8 @@"running": "현재 결과물을 검토하는 중","completed": "검토 완료","failed": "검토를 완료하지 못했습니다",- "openTask": "검토 작업 열기",- "readOnlyHint": "독립 작업 · 개발 메모리 없음 · 읽기 전용",+ "openTask": "검토 상세 보기",+ "readOnlyHint": "내부 검토 · 개발 메모리 없음 · 읽기 전용","noResult": "검토 결과가 반환되지 않았습니다","failure": {"reviewerClosed": "검토 작업이 완료되기 전에 닫혔습니다",diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.jsonindex ca6b5a97d2..adad5f49a7 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json@@ -6479,8 +6479,8 @@"running": "正在审查当前成果","completed": "审查完成","failed": "审查未完成",- "openTask": "打开审查任务",- "readOnlyHint": "独立任务 · 无开发记忆 · 只读",+ "openTask": "查看审查详情",+ "readOnlyHint": "内部审查 · 无开发记忆 · 只读","noResult": "审查任务没有返回可见结论","failure": {"reviewerClosed": "审查任务在完成前已关闭",diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.jsonindex de580c2078..e184df0f69 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json@@ -6482,8 +6482,8 @@"running": "正在審查當前成果","completed": "審查完成","failed": "審查未完成",- "openTask": "開啟審查任務",- "readOnlyHint": "獨立任務 · 無開發記憶 · 只讀",+ "openTask": "查看審查詳情",+ "readOnlyHint": "內部審查 · 無開發記憶 · 只讀","noResult": "審查任務沒有返回可見結論","failure": {"reviewerClosed": "審查任務在完成前已關閉",diff --git a/apps/desktop/src/shared/sessionSource.ts b/apps/desktop/src/shared/sessionSource.tsindex 5c7300bfa8..7908ef636c 100644--- a/apps/desktop/src/shared/sessionSource.ts+++ b/apps/desktop/src/shared/sessionSource.ts@@ -31,7 +31,8 @@ export function isReviewSessionSource(source: unknown): source is 'review' {// (2026-07-06 曾加入后按 Lizi 要求回退;2026-07-16 按 Lizi 要求重新加入,// 这次带 dialogue 归组,不再以 im-working-dir 聚成假项目组。)// scheduler / learn: 本机自动化会话,可见可点开看过程。-// review: /review 创建的本机只读独立审查任务,可从来源卡片或侧边栏打开。+// review: /review 创建的本机只读内部任务。它保留完整审计记录,但不进入普通任务+// 侧栏 / 最近任务 / 搜索;用户只从来源任务的 Review 卡片进入详情。// shared: .xdtshare 导入的分享会话,按 workingDir 归组。// plugin: 插件经 workspace 槽创建的工作区会话入口(空 draft,用户确认后建;// projectGrouping 对零消息的 plugin 会话豁免草稿判定,直接落项目分组)。@@ -47,7 +48,6 @@ export const DESKTOP_VISIBLE_SESSION_SOURCES: SessionSource[] = ['wecom','scheduler','learn',- 'review','shared','plugin',];diff --git a/docs/product-rules/review-product-direction.md b/docs/product-rules/review-product-direction.mdindex da8ad17370..7063d26945 100644--- a/docs/product-rules/review-product-direction.md+++ b/docs/product-rules/review-product-direction.md@@ -49,6 +49,10 @@ DeepSeek 等模型只要能在相应 harness 的普通任务中使用,也应- Finding 必须包含证据与优先级,并保持低噪音。默认突出高置信的正确性问题,把质量优化与正确性问题分开表达。- 结果回到来源任务,用户可从来源任务打开独立 Reviewer 任务。+- Reviewer 的独立运行隔离是内部实现细节:默认不进入普通任务侧栏、不参与最近任务排序、+ 未读或自动选中。来源任务中的 Review 卡片是默认入口,用户主动打开后查看只读审计详情。+- Review 的启动、进度更新和完成不得主动导航、抢占当前任务或改变当前主题;打开详情只由+ 用户点击触发。- 审阅对象或来源任务变化后,旧结论立即失效;异常、重启或关闭路径都必须 fail closed。- 完成后的 Reviewer 任务是可查看的审计记录,不能继续聊天,也不能修改模型、来源、权限、目录等冻结配置。