Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(browser-extension): a failed bridge startup is rebuilt by the next plugin request
Dashb3c0585bbca2
diff --git a/apps/desktop/src/main/cindy-brain/__tests__/browserExtensionSlot.test.ts b/apps/desktop/src/main/cindy-brain/__tests__/browserExtensionSlot.test.tsindex cc25b2aa7d..f6b068271d 100644--- a/apps/desktop/src/main/cindy-brain/__tests__/browserExtensionSlot.test.ts+++ b/apps/desktop/src/main/cindy-brain/__tests__/browserExtensionSlot.test.ts@@ -369,6 +369,27 @@ describe('browserExtensionSlot · 管子上行', () => {expect(again.sent.some(([, payload]) => (payload as { name?: string }).name === 'browser-extension-policy-request')).toBe(false);});+ // Review 2026-10-30 (Codex P2): a failed startup is rebuilt by the next request instead of staying failed.+ it('启动失败后下一次请求重建整套启动流程', async () => {+ const { slot, bridges, natives, settle, ghosts } = await makeSlot();+ slot.reconcile(ghosts);+ await vi.waitFor(() => expect(bridges).toHaveLength(1));+ // The first start fails (for example every compatible port is busy).+ bridges[0].start = async () => {+ throw new Error('ports busy');+ };+ await settle();+ expect(await slot.handleRequest('_root__my-browser', { kind: 'status' })).toMatchObject({+ ok: false,+ errorCode: 'HOST_NOT_READY',+ });+ // The request rebuilt the whole sequence: a new bridge started and the native binding was installed.+ await vi.waitFor(() => expect(bridges.at(-1)?.started).toBe(true));+ expect(bridges.length).toBeGreaterThan(1);+ expect(natives.length).toBeGreaterThan(0);+ expect(await slot.handleRequest('_root__my-browser', { kind: 'status' })).toMatchObject({ ok: true });+ });+// Review 2026-10-30 (Codex P1): a plugin cannot name host paths for Chrome to open.it('插件管子不能按路径上传', async () => {const { slot, bridges, settle, ghosts } = await makeSlot();diff --git a/apps/desktop/src/main/cindy-brain/browserExtensionSlot.ts b/apps/desktop/src/main/cindy-brain/browserExtensionSlot.tsindex 445d9a967c..1896b7edba 100644--- a/apps/desktop/src/main/cindy-brain/browserExtensionSlot.ts+++ b/apps/desktop/src/main/cindy-brain/browserExtensionSlot.ts@@ -116,6 +116,8 @@ interface Entry {closing: boolean;/** Paired clients as last persisted. */saved: SavedBrowserExtensionState;+ /** The startup sequence failed (for example every compatible port was busy); the next request rebuilds it. */+ startFailed?: true;/** Where the installed package came from; pairings never carry over to a package from elsewhere. */source: string;/** Serialises cache writes so an older write cannot land after a newer one. */@@ -260,6 +262,7 @@ export class GhostBrowserExtensionSlot {pageControl: needs.pageControl === true,});})().catch((err) => {+ entry.startFailed = true;this.deps.log?.warn('browser extension bridge failed to start', {instanceId,error: errorText(err),@@ -268,6 +271,15 @@ export class GhostBrowserExtensionSlot {this.entries.set(instanceId, entry);}+ private rebuild(failed: Entry): void {+ const { instanceId, ghost } = failed;+ if (this.disposed || this.entries.get(instanceId) !== failed) return;+ const ownerScopeKey = this.deps.ownerScopeKey();+ void this.stop(instanceId).then(() => {+ if (!this.disposed && !this.entries.has(instanceId)) this.start(instanceId, ghost, ownerScopeKey);+ });+ }+private stop(instanceId: string): Promise<void> {const entry = this.entries.get(instanceId);if (!entry || entry.closing) return this.stopping.get(instanceId) ?? Promise.resolve();@@ -361,6 +373,13 @@ export class GhostBrowserExtensionSlot {const req = payload as Record<string, unknown>;const { entry } = gate;await entry.ready;+ if (entry.startFailed) {+ // A failed startup would otherwise stay failed for good (no pairing request, no native binding)+ // even after the cause, such as busy ports, is gone. Rebuild it from the same request path the+ // plugin already retries on HOST_NOT_READY; there is no timer.+ this.rebuild(entry);+ return fail('HOST_NOT_READY', 'Cindy 正在重新启动浏览器扩展桥接,请稍后重试');+ }try {switch (req.kind) {case 'status': {