Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): 修复右侧分离窗合并空白
daviddf7b32ed636d
diff --git a/apps/desktop/src/main/right-sidebar-window/__tests__/controller.test.ts b/apps/desktop/src/main/right-sidebar-window/__tests__/controller.test.tsindex a8f2779e28..6599bbb67f 100644--- a/apps/desktop/src/main/right-sidebar-window/__tests__/controller.test.ts+++ b/apps/desktop/src/main/right-sidebar-window/__tests__/controller.test.ts@@ -531,13 +531,14 @@ describe('setDetached', () => {expect(win.destroy).toHaveBeenCalledOnce();});- it('drops persistable and stale-session handoff snapshots', () => {+ it('drops persistable snapshots but preserves a stale-session merge snapshot', () => {const h = makeHarness({ detached: true });h.controller.prewarm();const win = h.windows[0];markReady(h.controller, win);h.controller.setContext(ctx);h.controller.open({ userInitiated: false });+ h.controller.setContext({ ...ctx, sessionId: 's2' });h.controller.setDetached(false, {snapshots: [@@ -556,7 +557,22 @@ describe('setDetached', () => {],});- expect(h.sends.some((entry) => entry.channel === 'handoff-channel')).toBe(false);+ const handoffIndex = h.sends.findIndex((entry) => entry.channel === 'handoff-channel');+ expect(h.sends[handoffIndex]).toEqual({+ channel: 'handoff-channel',+ payload: {+ snapshots: [+ {+ sessionId: 'other',+ tabs: [],+ activeTabId: null,+ persistable: false,+ },+ ],+ },+ });+ expect(h.sendTargets[handoffIndex]).toBe(h.mainWin.webContents.id);+ expect(win.destroy).toHaveBeenCalledOnce();});});diff --git a/apps/desktop/src/main/right-sidebar-window/controller.ts b/apps/desktop/src/main/right-sidebar-window/controller.tsindex c4aadfaf86..8469835b15 100644--- a/apps/desktop/src/main/right-sidebar-window/controller.ts+++ b/apps/desktop/src/main/right-sidebar-window/controller.ts@@ -720,7 +720,9 @@ export class RsbWindowController {private sendTabHandoffToAttachedHost(handoff?: RsbWindowTabHandoff): void {const channel = this.deps.tabHandoffChannel;const main = this.deps.getMainWindow();- const filtered = this.filterTabHandoffForCurrentContext(handoff);+ // The detached renderer is the authoritative owner for this merge+ // snapshot, even if main has already advanced to another session.+ const filtered = this.filterTabHandoffForCurrentContext(handoff, true);if (!channel || !main || main.isDestroyed() || !filtered) return;this.deps.sendToWindow(main, channel, filtered);}@@ -743,14 +745,20 @@ export class RsbWindowController {private filterTabHandoffForCurrentContext(handoff?: RsbWindowTabHandoff,+ allowStaleSession = false,): RsbWindowTabHandoff | null {- const currentSessionId = this.lastContext?.available ? this.lastContext.sessionId : null;- if (!currentSessionId || !handoff) return null;+ if (!handoff) return null;- // Main owns the current context. Drop renderer-reported snapshots for any- // other session and never use a persistable snapshot as a DB replacement.+ // The sender is already validated by the IPC boundary. During merge-back,+ // keep the detached renderer's previous-session snapshot even when main+ // has already advanced to another context. During detach, still require+ // the main-owned snapshot to match main's current context. Never use a+ // persistable snapshot as a DB replacement.+ const currentSessionId = this.lastContext?.available ? this.lastContext.sessionId : null;const snapshots = handoff.snapshots.filter(- (snapshot) => !snapshot.persistable && snapshot.sessionId === currentSessionId,+ (snapshot) =>+ !snapshot.persistable &&+ (allowStaleSession || (currentSessionId !== null && snapshot.sessionId === currentSessionId)),);return snapshots.length > 0 ? { snapshots } : null;}diff --git a/apps/desktop/src/renderer/components/layout/MainLayout.tsx b/apps/desktop/src/renderer/components/layout/MainLayout.tsxindex af0524c355..8085a8170b 100644--- a/apps/desktop/src/renderer/components/layout/MainLayout.tsx+++ b/apps/desktop/src/renderer/components/layout/MainLayout.tsx@@ -925,6 +925,16 @@ export function MainLayout() {resetCachesForHostTransition();const sessionId = rightSidebarSessionIdRef.current;if (sessionId) {+ // The attached shell can mount before this parent transition effect.+ // Its initial hydrate then belongs to the cache generation that the+ // reset above invalidates. Start a fresh hydrate after the reset so a+ // persisted Windows session cannot remain on EMPTY_BUCKET forever.+ void ensureHydrated(sessionId).catch((err) => {+ applicationMenuLog.warn('rehydrate right sidebar after host transition failed', {+ sessionId,+ err,+ });+ });writeCollapsedFor(sessionId, false);setIsRightSidebarCollapsed(false);}diff --git a/apps/desktop/src/renderer/features/right-sidebar/__tests__/store.test.ts b/apps/desktop/src/renderer/features/right-sidebar/__tests__/store.test.tsindex a72680a869..182d5577d0 100644--- a/apps/desktop/src/renderer/features/right-sidebar/__tests__/store.test.ts+++ b/apps/desktop/src/renderer/features/right-sidebar/__tests__/store.test.ts@@ -262,6 +262,40 @@ describe('RSB store', () => {});});+ it('can rehydrate after a host transition invalidates an in-flight hydrate', async () => {+ let resolveInitial!: (value: {+ tabs: never[];+ activeTabId: null;+ }) => void;+ ipc.list.mockImplementationOnce(+ () =>+ new Promise((resolve) => {+ resolveInitial = resolve;+ }),+ );++ const initialHydration = store.ensureHydrated('host-transition-race');+ await vi.waitFor(() => expect(ipc.list).toHaveBeenCalledOnce());++ store.resetCachesForHostTransition();+ resolveInitial({ tabs: [], activeTabId: null });+ await initialHydration;+ expect(store.getBucket('host-transition-race').hydrated).toBe(false);++ ipc.list.mockResolvedValueOnce({+ tabs: [{ id: 'tab-after-transition', kind: 'web-browser', state: { url: 'about:blank' } }],+ activeTabId: 'tab-after-transition',+ });+ await store.ensureHydrated('host-transition-race');++ expect(store.getBucket('host-transition-race')).toEqual({+ hydrated: true,+ tabs: [{ id: 'tab-after-transition', kind: 'web-browser', state: { url: 'about:blank' } }],+ activeTabId: 'tab-after-transition',+ });+ expect(ipc.list).toHaveBeenCalledTimes(2);+ });+it('does not export a persistable local-DB bucket as a renderer handoff', async () => {await store.ensureHydrated('persisted-s1');expect(store.getTabSnapshot('persisted-s1')).toBeNull();diff --git a/packages/maker-core/src/agents/pi/__tests__/pi-rpc-resource-discovery.integration.test.ts b/packages/maker-core/src/agents/pi/__tests__/pi-rpc-resource-discovery.integration.test.tsindex 5993b648d4..c0f696291d 100644--- a/packages/maker-core/src/agents/pi/__tests__/pi-rpc-resource-discovery.integration.test.ts+++ b/packages/maker-core/src/agents/pi/__tests__/pi-rpc-resource-discovery.integration.test.ts@@ -868,7 +868,9 @@ describe.skipIf(!existsSync(PI_BINARY))('Pi v0.83.0 RPC resource discovery factssourceInfo: expect.objectContaining({path: path.join(explicitSkill, 'SKILL.md'),source: 'local',- scope: 'temporary',+ // Pi reports direct `--skill` paths as `project` on Windows and+ // `temporary` on macOS.+ scope: process.platform === 'win32' ? 'project' : 'temporary',}),}),]));@@ -932,7 +934,9 @@ describe.skipIf(!existsSync(PI_BINARY))('Pi v0.83.0 RPC resource discovery factsbaseDir: path.dirname(explicitSkill),path: explicitSkill,source: 'local',- scope: 'temporary',+ // Pi reports direct `--skill` paths as `project` on Windows and+ // `temporary` on macOS.+ scope: process.platform === 'win32' ? 'project' : 'temporary',}),}),]));@@ -962,7 +966,13 @@ describe.skipIf(!existsSync(PI_BINARY))('Pi v0.83.0 RPC resource discovery factsexpect(duplicates).toHaveLength(1);expect(duplicates[0]).toMatchObject({source: 'skill',- sourceInfo: { baseDir: first, source: 'local', scope: 'temporary' },+ sourceInfo: {+ baseDir: first,+ source: 'local',+ // The bundled Pi binary uses `project` on Windows and `temporary` on+ // macOS for direct explicit paths.+ scope: process.platform === 'win32' ? 'project' : 'temporary',+ },});});