Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): 避免预热侧栏清空浏览器会话
DavidShend00a46f4f3e5
diff --git a/apps/desktop/src/renderer/features/right-sidebar/RightSidebarShell.tsx b/apps/desktop/src/renderer/features/right-sidebar/RightSidebarShell.tsxindex d6610c5984..8694521de2 100644--- a/apps/desktop/src/renderer/features/right-sidebar/RightSidebarShell.tsx+++ b/apps/desktop/src/renderer/features/right-sidebar/RightSidebarShell.tsx@@ -213,17 +213,20 @@ export function RightSidebarShell({useEffect(() => {// Phase 5: 推送当前焦点 RSB sessionId 给 main,让 RsbWebviewBackend 拿到。// null 也推(切到非 RSB 路由时),让 main 端清掉 active session — 否则- // 之前的 sessionId 会成 stale 引用。setActiveSession 失败容错(preload 未就绪)。- void window.electronAPI?.rsbBrowserBridge- ?.setActiveSession({ sessionId })- .catch(() => undefined);+ // 之前的 sessionId 会成 stale 引用。隐藏的分离窗口只是预热/待命实例,不能+ // 覆盖主窗口当前的浏览器 session。setActiveSession 失败容错(preload 未就绪)。+ if (shellVisible) {+ void window.electronAPI?.rsbBrowserBridge+ ?.setActiveSession({ sessionId })+ .catch(() => undefined);+ }if (!sessionId) return;// 首次访问该 sessionId 时触发 IPC list 拉取;命中 cache 直接 noop。// 完成后 setBucket → notify → subscribeBucket 唤醒 useSyncExternalStore 重渲染。void ensureHydrated(sessionId).catch((err) => {log.error('ensureHydrated failed', { sessionId, err });});- }, [sessionId]);+ }, [sessionId, shellVisible]);const projectedTabs = useMemo(() => projectIOSSimulatorTabs(bucket.tabs, bucket.activeTabId, iosSimulatorPluginAvailable),diff --git a/apps/desktop/src/renderer/features/right-sidebar/__tests__/RightSidebarShell.test.ts b/apps/desktop/src/renderer/features/right-sidebar/__tests__/RightSidebarShell.test.tsindex 10adbb8478..d0c2290510 100644--- a/apps/desktop/src/renderer/features/right-sidebar/__tests__/RightSidebarShell.test.ts+++ b/apps/desktop/src/renderer/features/right-sidebar/__tests__/RightSidebarShell.test.ts@@ -266,6 +266,34 @@ describe('RightSidebarShell empty state', () => {delete (window as unknown as { electronAPI?: unknown }).electronAPI;});+ it('does not replace the active browser session while the detached shell is hidden', async () => {+ const setActiveSession = window.electronAPI.rsbBrowserBridge.setActiveSession;+ const view = render(+ createElement(RightSidebarShell, {+ sessionId: 's1',+ workdir: '/tmp/repo',+ remoteHostId: null,+ shellVisible: false,+ isMac: true,+ }),+ );++ await waitFor(() => expect(tabsIpc.list).toHaveBeenCalledWith({ sessionId: 's1' }));+ expect(setActiveSession).not.toHaveBeenCalled();++ view.rerender(+ createElement(RightSidebarShell, {+ sessionId: 's1',+ workdir: '/tmp/repo',+ remoteHostId: null,+ shellVisible: true,+ isMac: true,+ }),+ );++ await waitFor(() => expect(setActiveSession).toHaveBeenCalledWith({ sessionId: 's1' }));+ });+it('mounts only the active body first, then idle-mounts and keeps the rest alive', async () => {const idleCallbacks: IdleRequestCallback[] = [];Object.defineProperty(window, 'requestIdleCallback', {