Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(orca): persist remote Worker Agent location in proxy
david952b3036ed9e
diff --git a/apps/desktop/src/main/localDb/__tests__/orcaTeamStore.test.ts b/apps/desktop/src/main/localDb/__tests__/orcaTeamStore.test.tsindex 07dad66855..dd2eb34e98 100644--- a/apps/desktop/src/main/localDb/__tests__/orcaTeamStore.test.ts+++ b/apps/desktop/src/main/localDb/__tests__/orcaTeamStore.test.ts@@ -154,6 +154,29 @@ describe('orcaTeamStore', () => {expect(await store.listOrphanRemoteWorkerOpens()).toEqual([expect.objectContaining({ remoteSessionId: 'orphan-1' })]);});+ // PR #6787, unit: real addRemoteWorker transaction + listWorkersByLead reread.+ // Existing tests only associated an existing proxy and missed proxy creation.+ // B executes the task while C supplies the Agent; explicit local / old-host+ // omission must stay null rather than acquire B's execution-device identity.+ it.each(['device-c', null, undefined])('retains the remote proxy Agent location %s across a Worker list refresh', async agentDeviceId => {+ const store = await import('../orcaTeamStore.js');+ const client = createTestDbClient();+ setCurrentDbClient(client, 'test-user');+ await seedOrcaWorkers(client);+ await store.addRemoteWorker({ workerId: 'remote-worker', teamId: 'team-1', proxySessionId: 'remote-proxy',+ deviceId: 'device-b', remoteSessionId: 'remote-1', label: 'remote', role: 'developer',+ proxySession: { title: 'Remote', agentKind: 'codex', model: 'remote-model', effort: null,+ permissionMode: 'auto', fastMode: false,+ ...(agentDeviceId !== undefined ? { agentDeviceId } : {}),+ },+ });+ const workers = await store.listWorkersByLead('lead-session-1');+ expect(workers.find(worker => worker.id === 'remote-worker')).toMatchObject({+ session: { agentDeviceId: agentDeviceId ?? null },+ executionDevice: { deviceId: 'device-b', remoteSessionId: 'remote-1' },+ });+ });+it('keeps a rolled-back remote Worker available for cleanup across database rereads', async () => {const store = await import('../orcaTeamStore.js');const client = createTestDbClient();diff --git a/apps/desktop/src/main/localDb/client/tx/types.ts b/apps/desktop/src/main/localDb/client/tx/types.tsindex 237e62c463..12822688e6 100644--- a/apps/desktop/src/main/localDb/client/tx/types.ts+++ b/apps/desktop/src/main/localDb/client/tx/types.ts@@ -275,6 +275,7 @@ export interface OrcaRemoteWorkerProxySessionSeed {effort: string | null;permissionMode: string;fastMode: boolean | 'ultrafast';+ agentDeviceId?: string | null;}export interface OrcaUpsertWorkerArgs {diff --git a/apps/desktop/src/main/localDb/worker/opHandlers/tx.ts b/apps/desktop/src/main/localDb/worker/opHandlers/tx.tsindex 0d8760aad5..61d3a37c31 100644--- a/apps/desktop/src/main/localDb/worker/opHandlers/tx.ts+++ b/apps/desktop/src/main/localDb/worker/opHandlers/tx.ts@@ -3543,12 +3543,13 @@ function orcaUpsertWorker(db: Database.Database, args: unknown): void {const remote = asRecord(payload.remoteExecution, 'remoteExecution');if (remote.proxySession !== undefined) {const proxy = asRecord(remote.proxySession, 'remoteExecution.proxySession');- db.prepare("INSERT INTO sessions (id, title, working_dir, workspace_kind, model, effort, permission_mode, fast_mode, status, agent_kind, orca_role, source, created_at, updated_at) VALUES (?, ?, NULL, 'project', ?, ?, ?, ?, 'active', ?, 'worker', 'desktop', ?, ?)").run(+ db.prepare("INSERT INTO sessions (id, title, working_dir, workspace_kind, model, effort, permission_mode, fast_mode, status, agent_kind, orca_role, source, created_at, updated_at, agent_device_id) VALUES (?, ?, NULL, 'project', ?, ?, ?, ?, 'active', ?, 'worker', 'desktop', ?, ?, ?)").run(sessionId, expectString(proxy.title, 'proxySession.title'),expectString(proxy.model, 'proxySession.model'),proxy.effort == null ? 'high' : expectString(proxy.effort, 'proxySession.effort'),expectString(proxy.permissionMode, 'proxySession.permissionMode'), fastModeToStorage(proxy.fastMode),expectString(proxy.agentKind, 'proxySession.agentKind'), now, now,+ proxy.agentDeviceId == null ? null : expectString(proxy.agentDeviceId, 'proxySession.agentDeviceId'),);}}diff --git a/apps/desktop/src/main/maker-ipc/__tests__/orcaRemoteWorkers.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/orcaRemoteWorkers.test.tsindex 3ed12d278e..bd33c1f99f 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/orcaRemoteWorkers.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/orcaRemoteWorkers.test.ts@@ -247,6 +247,15 @@ describe('openRemoteWorker', () => {if (supported) {expect(result).toMatchObject({ ok: true, model: 'remote-only', agentDeviceId: 'provider-pc', providerId: 'openai' });expect(remoteInvoke.mock.calls.find(call => call[1] === 'maker:orca:remote-worker:open')?.[2][0]).toMatchObject({ agentDeviceId: 'provider-pc' });+ // PR #6787: the transient result used to retain the Agent computer while+ // the proxy seed lost it. Unit regression through open + association;+ // the store needs the admitted location to retain it after a refresh.+ if (!result.ok) throw Error('expected successful open');+ await workers.recordRemoteWorker({ ...openInput, proxySessionId: result.proxySessionId,+ proxySession: result.proxySession, remoteSessionId: result.remoteSessionId });+ expect(store.addRemoteWorker).toHaveBeenCalledWith(expect.objectContaining({+ proxySession: expect.objectContaining({ agentDeviceId: 'provider-pc' }),+ }));} else {expect(result).toMatchObject({ ok: false, errorCode: 'UNSUPPORTED_CAPABILITY' });expect(remoteInvoke.mock.calls.some(call => call[1] === 'maker:orca:remote-worker:open')).toBe(false);diff --git a/apps/desktop/src/main/maker-ipc/orcaRemoteWorkers.ts b/apps/desktop/src/main/maker-ipc/orcaRemoteWorkers.tsindex d4a8847331..5ab4c38f8d 100644--- a/apps/desktop/src/main/maker-ipc/orcaRemoteWorkers.ts+++ b/apps/desktop/src/main/maker-ipc/orcaRemoteWorkers.ts@@ -537,6 +537,7 @@ export function createOrcaRemoteWorkers(deps: OrcaRemoteWorkersDeps) {: input.effort && EFFORTS.has(input.effort) ? input.effort : null,permissionMode: input.permissionMode,fastMode: opened.fastMode ?? (input.fast ?? false),+ ...(opened.agentDeviceId !== undefined ? { agentDeviceId: opened.agentDeviceId } : {}),};creationOwners.set(proxySessionId, owner);return {