Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(sidebar): 升级时把旧版收进气泡的停靠面板迁成已关闭,不自动弹出
Dash04d532aee39b
diff --git a/apps/desktop/src/renderer/features/right-sidebar/__tests__/globalTabs.test.ts b/apps/desktop/src/renderer/features/right-sidebar/__tests__/globalTabs.test.tsindex 8fd4148438..b929e61caf 100644--- a/apps/desktop/src/renderer/features/right-sidebar/__tests__/globalTabs.test.ts+++ b/apps/desktop/src/renderer/features/right-sidebar/__tests__/globalTabs.test.ts@@ -161,7 +161,9 @@ describe('globalTabs', () => {// 缺省 position 的停靠面板 → left(与历史停靠面板一致);mainView.side 优先。expect(defaultGroupForGhost(ghost(undefined))).toBe('left');- expect(defaultGroupForGhost(ghost(undefined, { open: 'sidebar', side: 'right' }))).toBe('right');+ expect(defaultGroupForGhost(ghost(undefined, { open: 'sidebar', side: 'right' }))).toBe(+ 'right',+ );expect(defaultGroupForGhost(ghost(undefined, { open: 'page' }))).toBe('right');});// 测试价值@@ -230,4 +232,31 @@ describe('globalTabs', () => {expect(ids).not.toContain('g_p0');expect(ids).not.toContain('g_p1');});++ // 测试价值+ // - 生产入口与可观察结果:reconcileGlobalPluginTabs 读升级前 `xdt:ghostPanelBubble:v1`;可观察的是+ // 旧版里被收进气泡(最小化)的停靠面板升级后不自动变成可见页签、记入已关闭,其余面板照常出现。+ // - Bug / 规则依据:PR #6468 review「迁移最小化面板」;存量插件兼容红线(用户的隐藏偏好不丢)。+ // - 现有覆盖缺口:上一个用例只覆盖全部面板自动迁移,没有旧最小化状态。+ // - 最小失败输入:两个面板插件,其中一个在旧键里 minimized:true。+ it('keeps a panel the user had minimized hidden after upgrade instead of auto-adding it', () => {+ window.localStorage.setItem(+ 'xdt:ghostPanelBubble:v1',+ JSON.stringify({ p0: { minimized: true }, p1: { minimized: false, x: 1, y: 2 } }),+ );+ const ghosts = ['p0', 'p1'].map((id) => ({+ manifest: { id, name: id, panel: { html: 'p.html' } },+ enabled: true,+ })) as unknown as import('../../../../shared/ghost').InstalledGhost[];+ reconcileGlobalPluginTabs(ghosts);+ expect(getGlobalTabs().map((tab) => tab.id)).toEqual(['g_p1']);+ expect(getGlobalTabsSnapshot().dismissedInstanceIds).toEqual(['p0']);+ // 再对齐一次结果稳定;用户从「+」重开后正常出现,不再被旧记录挡住。+ reconcileGlobalPluginTabs(ghosts);+ expect(getGlobalTabs()).toHaveLength(1);+ addGlobalPluginTab('p0', { ghost: ghosts[0] });+ expect(getGlobalTabs().map((tab) => tab.id)).toEqual(['g_p1', 'g_p0']);+ reconcileGlobalPluginTabs(ghosts);+ expect(getGlobalTabs()).toHaveLength(2);+ });});diff --git a/apps/desktop/src/renderer/features/right-sidebar/globalTabs.ts b/apps/desktop/src/renderer/features/right-sidebar/globalTabs.tsindex ade323cb0a..ff5e2f2593 100644--- a/apps/desktop/src/renderer/features/right-sidebar/globalTabs.ts+++ b/apps/desktop/src/renderer/features/right-sidebar/globalTabs.ts@@ -439,6 +439,26 @@ export function isGlobalTabCapableGhost(ghost: InstalledGhost): boolean {);}+/** 升级前停靠面板「最小化到气泡」的持久化键(旧实现已移除,这里只读一次做迁移)。 */+const LEGACY_PANEL_BUBBLE_KEY = 'xdt:ghostPanelBubble:v1';++/** 旧版里被用户收进气泡(= 主动隐藏)的插件实例;读失败 / 坏数据视为没有。 */+function legacyMinimizedInstanceIds(): Set<string> {+ const out = new Set<string>();+ try {+ const raw = window.localStorage.getItem(LEGACY_PANEL_BUBBLE_KEY);+ if (!raw) return out;+ const parsed: unknown = JSON.parse(raw);+ if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) return out;+ for (const [id, entry] of Object.entries(parsed)) {+ if ((entry as { minimized?: unknown } | null)?.minimized === true) out.add(id);+ }+ } catch {+ // 旧数据读不出来就当没有:最坏是面板作为页签重新出现,用户可关掉。+ }+ return out;+}+/*** 与已装清单对齐(启动 + ghosts:changed):* - 已启用、声明停靠面板、未被用户关掉的插件 → 自动加页签(存量插件兼容:@@ -452,16 +472,23 @@ export function reconcileGlobalPluginTabs(ghosts: readonly InstalledGhost[]): volet tabs = current.tabs.filter((tab) =>installed.has((tab.state as PluginViewTabState).instanceId),);- const dismissed = current.dismissedInstanceIds.filter((id) => installed.has(id));+ let dismissed = current.dismissedInstanceIds.filter((id) => installed.has(id));let placed = current.placedInstanceIds.filter((id) => installed.has(id));const windowed = current.windowInstanceIds.filter((id) => installed.has(id));const present = new Set(tabs.map((tab) => (tab.state as PluginViewTabState).instanceId));+ let legacyMinimized: Set<string> | undefined;for (const [instanceId, ghost] of installed) {if (!isAutoGlobalPanelGhost(ghost)) continue;if (present.has(instanceId) || dismissed.includes(instanceId)) continue;const tabId = globalTabIdForInstance(instanceId);// 首次出现:按插件声明放默认边(存量 panel.position 的插件回到它原来停的那一边)。if (!placed.includes(instanceId)) {+ // 升级前用户把它收进了气泡 = 主动隐藏:迁成「已关闭」,不自动弹出;「+」菜单里可重开。+ legacyMinimized ??= legacyMinimizedInstanceIds();+ if (legacyMinimized.has(instanceId)) {+ dismissed = [...dismissed, instanceId];+ continue;+ }setTabGroup(tabId, defaultGroupForGhost(ghost, 'panel'));placed = [...placed, instanceId];}