Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(bots): detect legacy execution location changes
ylliuuu6604c8019ec17d
diff --git a/apps/desktop/src/main/localDb/ipc/__tests__/botCanonicalSession.test.ts b/apps/desktop/src/main/localDb/ipc/__tests__/botCanonicalSession.test.tsindex a4b610104c..ef08eacf78 100644--- a/apps/desktop/src/main/localDb/ipc/__tests__/botCanonicalSession.test.ts+++ b/apps/desktop/src/main/localDb/ipc/__tests__/botCanonicalSession.test.ts@@ -792,6 +792,22 @@ describe('Bot canonical Session lifecycle', () => {} finally { vi.mocked(control.validateTaskModel).mockResolvedValue(true); }});+ it('validates a legacy location-only selection before persisting settings', async () => {+ const route = { harness: 'codex', model: 'gpt-6-astra', providerId: 'openai', effort: 'high', fastMode: false };+ h.sqlite!.prepare('UPDATE bot_profile_versions SET capabilities_json = ? WHERE bot_id = ? AND version = 1')+ .run(JSON.stringify(route), 'bot-1');+ const before = h.sqlite!.prepare("SELECT * FROM bot_profile_versions WHERE bot_id = 'bot-1'").all();+ const control = await import('../../../maker-ipc/appDefaultModelControl.js');+ vi.mocked(control.validateTaskModel).mockClear().mockResolvedValue(false);+ try {+ await expect(invoke('local-db:bots:update', {+ id: 'bot-1', capabilities: { agentDeviceId: 'share:unavailable-location' },+ })).rejects.toThrow('Model route unavailable');+ expect(control.validateTaskModel).toHaveBeenCalledWith({ ...route, agentDeviceId: 'share:unavailable-location' });+ expect(h.sqlite!.prepare("SELECT * FROM bot_profile_versions WHERE bot_id = 'bot-1'").all()).toEqual(before);+ } finally { vi.mocked(control.validateTaskModel).mockResolvedValue(true); }+ });+it.each(['rename', 'skills'])('allows legacy chain-only profile maintenance with an unavailable provider: %s', async edit => {const id = 'legacy-chain-only';await invoke('local-db:bots:create', { id, name: 'Legacy' });diff --git a/apps/desktop/src/main/localDb/worker/opHandlers/__tests__/botTx.test.ts b/apps/desktop/src/main/localDb/worker/opHandlers/__tests__/botTx.test.tsindex 72c3e25380..61bd6636c2 100644--- a/apps/desktop/src/main/localDb/worker/opHandlers/__tests__/botTx.test.ts+++ b/apps/desktop/src/main/localDb/worker/opHandlers/__tests__/botTx.test.ts@@ -97,8 +97,9 @@ describe('Bot named worker transactions', () => {const row = db.prepare(`SELECT p.status, v.capabilities_json AS capabilities FROM bot_profiles pJOIN bot_profile_versions v ON v.bot_id = p.id AND v.version = p.current_versionWHERE p.id = 'saved-bot'`).get() as { status: string; capabilities: string };+ const config = JSON.parse(row.capabilities);return row.status === 'active' ? {- chain: normalizeBotModelChain(JSON.parse(row.capabilities).modelChain), current,+ chain: normalizeBotModelChain(config.modelChain, config), current,hasRuntimeOverride: false, scheduledModelBaseline: readBaseline(),} : null;},@@ -195,6 +196,23 @@ describe('Bot named worker transactions', () => {expect(h.readBaseline()).toBeNull();});+ it('keeps a legacy location-only save across restart and old automation cleanup', async () => {+ const h = savedModelFixture();+ const legacy = { harness: 'codex', model: 'old', providerId: 'connected-custom', effort: 'high', fastMode: false };+ db.prepare('UPDATE bot_profile_versions SET capabilities_json = ? WHERE bot_id = ? AND version = 1')+ .run(JSON.stringify(legacy), 'saved-bot');+ h.pause(true);+ h.save('old', 1, { capabilitiesJson: JSON.stringify({ ...legacy, agentDeviceId: 'share:new-location' }) });+ expect(JSON.parse(h.readBaseline()!)).toMatchObject({ pendingBotProfileVersion: 2 });+ await h.scope.restore('saved-session', 'automation');+ expect(h.current().model).toBe('temporary');+ h.pause(false);+ await h.reconcile()('saved-session');+ await h.scope.restore('saved-session', 'automation');+ expect(h.current()).toMatchObject({ model: 'old', agentDeviceId: 'share:new-location' });+ expect(h.readBaseline()).toBeNull();+ });+it('keeps the durable save and old baseline on failure, without restoring it while paused', async () => {const h = savedModelFixture();h.pause(true);diff --git a/apps/desktop/src/shared/botModelChain.ts b/apps/desktop/src/shared/botModelChain.tsindex 98e2a79c39..f31f16fc6d 100644--- a/apps/desktop/src/shared/botModelChain.ts+++ b/apps/desktop/src/shared/botModelChain.ts@@ -121,7 +121,7 @@ export function botProfileModelSelectionChanged(previous: Record<string, unknown// shape the settings save uses, so adding mirror fields is not a model edit.previous = normalizeBotProfileModelChain(previous);next = normalizeBotProfileModelChain(next);- return ['modelChainOverride', 'modelOverride', 'modelChain', 'harness', 'model', 'providerId', 'effort', 'fastMode']+ return ['modelChainOverride', 'modelOverride', 'modelChain', 'harness', 'model', 'providerId', 'agentDeviceId', 'effort', 'fastMode'].some((key) => JSON.stringify(previous[key] ?? null) !== JSON.stringify(next[key] ?? null));}