Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(agent-island): 伙伴身份读取直到代次稳定才提交,不再限定重读次数
Dashea50fce4703e
diff --git a/apps/desktop/src/main/agent-island/__tests__/service.test.ts b/apps/desktop/src/main/agent-island/__tests__/service.test.tsindex fe349a46dc..581beba19e 100644--- a/apps/desktop/src/main/agent-island/__tests__/service.test.ts+++ b/apps/desktop/src/main/agent-island/__tests__/service.test.ts@@ -1832,10 +1832,18 @@ describe('AgentIslandService native publishing', () => {service.handleUserPrompt({ sessionId: 's1', agentKind: 'claude-code', workingDir: '/home' }, 'hi');await vi.waitFor(() => expect(mocks.readAgentIslandCompanion).toHaveBeenCalledTimes(1));+ // Several edits during one slow first read: only a read that saw none of them may commit.service.handleCompanionProfileChanged('b1');+ service.handleCompanionProfileChanged('b1');+ service.handleCompanionProfileChanged('b1');+ let releaseSecond!: (identity: AgentIslandCompanionIdentity) => void;+ mocks.readAgentIslandCompanion.mockImplementationOnce(() => new Promise((resolve) => { releaseSecond = resolve; }));releaseFirst(named('旧名字'));+ await vi.waitFor(() => expect(mocks.readAgentIslandCompanion).toHaveBeenCalledTimes(2));+ service.handleCompanionProfileChanged('b1');+ releaseSecond(named('中间名字'));await vi.waitFor(() => expect(publish.mock.calls.at(-1)?.[0].sessions[0]?.title).toBe('新名字'));- expect(mocks.readAgentIslandCompanion).toHaveBeenCalledTimes(2);+ expect(mocks.readAgentIslandCompanion).toHaveBeenCalledTimes(3);});it('retries a remote companion avatar after a failed read instead of keeping the glyph forever', async () => {diff --git a/apps/desktop/src/main/agent-island/service.ts b/apps/desktop/src/main/agent-island/service.tsindex cff2855959..72b475fe72 100644--- a/apps/desktop/src/main/agent-island/service.ts+++ b/apps/desktop/src/main/agent-island/service.ts@@ -172,7 +172,6 @@ const REMOTE_AUTH_ERROR_FALLBACK_MS = 30_000;const ISLAND_ENTRY_ALERT_TTL_MS = 60_000;const MAX_ISLAND_ENTRY_SESSION_ID_LENGTH = 128;const REMOTE_COMPANION_ARTWORK_RETRY_MS = 60_000;-const COMPANION_READ_MAX_ATTEMPTS = 3;const MAX_ISLAND_ENTRY_ID_LENGTH = 32;interface AgentIslandSessionMeta {@@ -1460,19 +1459,19 @@ export class AgentIslandService {* - A read is superseded (undefined) when a newer read for the same Session started, so an* older, slower one never overwrites it.* - A change that lands while a read is in flight (even before the Session's companion is- * known, so no refresh could target it) bumps the epoch; that read is repeated.+ * known, so no refresh could target it) bumps the epoch; that read is repeated until a read+ * finishes with no change during it. Each repeat needs a new user edit, so this is not a+ * loop that can spin on its own, and giving up would leave an older identity on the card.*/private async readCompanionIdentityFresh(sessionId: string): Promise<AgentIslandCompanionIdentity | null | undefined> {const seq = (this.companionReadSeq.get(sessionId) ?? 0) + 1;this.companionReadSeq.set(sessionId, seq);- let identity: AgentIslandCompanionIdentity | null = null;- for (let attempt = 0; attempt < COMPANION_READ_MAX_ATTEMPTS; attempt += 1) {+ for (;;) {const epoch = this.companionChangeEpoch;- identity = await readAgentIslandCompanion(sessionId);+ const identity = await readAgentIslandCompanion(sessionId);if (this.companionReadSeq.get(sessionId) !== seq) return undefined;if (epoch === this.companionChangeEpoch) return identity;}- return identity;}private refreshCompanionSessions(matches: (identity: AgentIslandCompanionIdentity) => boolean): void {