Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): restore queued follow-up permission from DB
Cursor Agent2ca7f8499ff1
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/botTaskCoordination.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/botTaskCoordination.test.tsindex 37ee3e2212..3f71049626 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/botTaskCoordination.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/botTaskCoordination.test.ts@@ -9,7 +9,7 @@ import { buildMakerUserMessage, sanitizeQueuedMessageForPersistence, type AgentIimport { redactMessageOriginForSharedGuest, redactQueueItemForSharedGuest } from '../../device-link/sharedTaskMessageOrigin';import { rebuildSessionQueueItem } from '../sessionControlService';import { projectCoordinationOutput } from '../coordinationOutput';-import type { AgentEvent } from '@cindy/maker-core';+import { AUTO_REVIEW_DELEGATED_CONTINUATION, type AgentEvent } from '@cindy/maker-core';import { stripMainOnlySendOpts } from '../mobileClientPromptNote';const h = vi.hoisted(() => ({ db: null as ReturnType<typeof drizzle> | null }));@@ -105,8 +105,10 @@ it('uses the registered host entry for both quiet and explicitly visible delegatconst send = vi.fn(async (params: unknown) => params);let currentOwner = true;const dispatch = new Function('captureDataOwnerBroadcastScope', 'isDataOwnerBroadcastScopeCurrent',- 'classifySessionMessagePurpose', 'coordinationInput', 'sendToSessionInternal', code)(- () => 'owner', () => currentOwner, classifySessionMessagePurpose, coordinationInput, send);+ 'classifySessionMessagePurpose', 'coordinationInput', 'sendToSessionInternal',+ 'AUTO_REVIEW_DELEGATED_CONTINUATION', code)(+ () => 'owner', () => currentOwner, classifySessionMessagePurpose, coordinationInput, send,+ AUTO_REVIEW_DELEGATED_CONTINUATION);await dispatch({ dispatcherSessionId: 'child', targetSessionId: 'parent', message: 'Agreement' });expect(send).toHaveBeenLastCalledWith(expect.objectContaining({ forceQueue: true, botTaskCoordination: receipt,persistedContent: '[UI_ACTION_TRIGGER]Agreement', autoReviewUserText: { kind: 'delegated-continuation' } }));diff --git a/apps/desktop/src/main/maker-ipc/__tests__/makerSendTransaction.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/makerSendTransaction.test.tsindex eda4b262c9..ff80d049ba 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/makerSendTransaction.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/makerSendTransaction.test.ts@@ -3330,6 +3330,25 @@ describe('session-agent-switch handoff injection', () => {expect(bootstrapOpts.resumeSessionId).toBeUndefined();});+ it('lazy-create uses the current DB permission after reconcile, not the queued snapshot', async () => {+ const reconcile = vi.fn(async (_sessionId: string, co: MakerSessionCreateOpts) => {+ co.permissionMode = 'ask';+ });+ const { deps } = createDeps({+ getSession: vi.fn(() => undefined),+ reconcileCreateOptsWithDb: reconcile,+ });++ await createMakerSendTransaction(deps).sendToAgentAccepted(+ 'session-1',+ 'CI failed; repair and push the PR',+ { agentKind: 'claude-code', workingDir: '/tmp/w', permissionMode: 'bypassPermissions' },+ {},+ );+ expect(reconcile).toHaveBeenCalledTimes(1);+ expect(vi.mocked(deps.bootstrapSession).mock.calls[0][0].permissionMode).toBe('ask');+ });+it('发送前的准备期间被停止(如供应商组在等原电脑恢复)→ 不再打开会话,按「派发前取消」返回', async () => {const controller = new AbortController();const getSession = vi.fn((): MakerSendTransactionSession | null => null);diff --git a/apps/desktop/src/main/maker-ipc/__tests__/sendToSessionLazyResumePermission.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/sendToSessionLazyResumePermission.test.tsindex 22815318fb..5c549fdc5c 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/sendToSessionLazyResumePermission.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/sendToSessionLazyResumePermission.test.ts@@ -57,4 +57,14 @@ describe('sendToSessionInternal lazy-resume permission mode', () => {const select = sessionsSource.slice(sessionsSource.indexOf('async function selectSessionRowSnapshot('));expect(select.slice(0, select.indexOf('.from(sessions)'))).toContain('permissionMode: sessions.permissionMode,');});++ it('refreshes permissionMode from DB before a queued follow-up starts the harness', () => {+ const start = registerSource.indexOf('async function reconcileCreateOptsAgainstDb(');+ const end = registerSource.indexOf('const agentSwitchDeps:', start);+ expect(start).toBeGreaterThanOrEqual(0);+ expect(end).toBeGreaterThan(start);+ const reconcile = registerSource.slice(start, end);+ expect(reconcile).toContain('permissionMode: sessions.permissionMode,');+ expect(reconcile).toContain('co.permissionMode = permissionModeOrAsk(row.permissionMode);');+ });});diff --git a/apps/desktop/src/main/maker-ipc/register.ts b/apps/desktop/src/main/maker-ipc/register.tsindex 022036384a..d45507d1d6 100644--- a/apps/desktop/src/main/maker-ipc/register.ts+++ b/apps/desktop/src/main/maker-ipc/register.ts@@ -9695,6 +9695,8 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)// 残留在 renderer store / 排队项里的旧 agentKind/resumeSessionId 若原样 spawn,// 会把会话劫持回旧引擎且丢交接注入(规则 9:代码兜底)。send 事务与// GET_CONTEXT_USAGE 的 lazy 分支共用(后者无校正曾是审计实锤缺口)。+ // 权限档同样是会话级设置:forceQueue 入队快照不能锁死排队期间的切档,冷启动必须+ // 再读一次当前落库值,否则降档后仍免确认、升档后仍重复询问。async function reconcileCreateOptsAgainstDb(sessionId: string, co: CreateOpts): Promise<void> {try {const db = getDbClient().drizzle;@@ -9706,6 +9708,7 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)providerId: sessions.providerId,effort: sessions.effort,fastMode: sessions.fastMode,+ permissionMode: sessions.permissionMode,agentDeviceId: sessions.agentDeviceId,remoteHostId: sessions.remoteHostId,})@@ -9748,6 +9751,7 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)co.providerId = row.providerId;co.effort = (row.effort ?? undefined) as CreateOpts['effort'];co.fastMode = !!row.fastMode;+ co.permissionMode = permissionModeOrAsk(row.permissionMode);} catch (error) {// context.rebuild clears sdk_session_id before the next bootstrap. If the// DB truth cannot be read, continuing with caller-supplied opts could@@ -10505,6 +10509,8 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)* Host 持有的恢复策略:目标会话不在运行、需要 lazy-resume 时,按会话落库的权限档* 启动,而不是 main 侧通路的缺省 bypass。插件任务的档位来自用户的任务设置,只能由* 宿主的插件派发入口显式要求,不从来源字段推断(#5788)。+ * forceQueue 会在这条 lazy-resume 之前入队返回;排队项真正启动前由+ * reconcileCreateOptsAgainstDb 再读当前落库档位,不使用入队时的旧快照。*/resumeWithStoredPermissionMode?: boolean;}): Promise<SendToSessionInternalResult> {diff --git a/apps/desktop/src/renderer/__tests__/sessionAgentSwitchRemoteRouting.test.ts b/apps/desktop/src/renderer/__tests__/sessionAgentSwitchRemoteRouting.test.tsindex e099c16dad..cb53c01274 100644--- a/apps/desktop/src/renderer/__tests__/sessionAgentSwitchRemoteRouting.test.ts+++ b/apps/desktop/src/renderer/__tests__/sessionAgentSwitchRemoteRouting.test.ts@@ -904,8 +904,10 @@ describe('ChatInput 的入口门控与调用路由', () => {const body = hostSource.slice(start, end);expect(body).toContain('effort: sessions.effort,');expect(body).toContain('fastMode: sessions.fastMode,');+ expect(body).toContain('permissionMode: sessions.permissionMode,');expect(body).toContain("co.effort = (row.effort ?? undefined) as CreateOpts['effort'];");expect(body).toContain('co.fastMode = !!row.fastMode;');+ expect(body).toContain('co.permissionMode = permissionModeOrAsk(row.permissionMode);');});it('Orca 与角色未加载会话都 fail-closed:只有完整元数据确认非协同后开放入口', () => {