diff --git a/apps/desktop/src/App.vue b/apps/desktop/src/App.vue index 1b404ed6f9..e9eeffb3ea 100644 --- a/apps/desktop/src/App.vue +++ b/apps/desktop/src/App.vue @@ -402,6 +402,7 @@ const immediateSyncing = ref(false); const showDriverStore = computed(() => driverStoreTabOpen.value && driverStoreActive.value); const showPluginCenter = computed(() => pluginCenterTabOpen.value && pluginCenterActive.value); const showSettingsPage = computed(() => Boolean(settingsPageTabOpen.value && settingsStore.settingsPageActive)); +const isSpecialPageActive = computed(() => !isDetachedWindowContext && (driverStoreActive.value || pluginCenterActive.value || settingsStore.settingsPageActive)); const showQuickOpen = ref(false); const quickOpenForceContent = ref(false); const showTabSwitcher = ref(false); @@ -1016,7 +1017,7 @@ const specialPageTabs = computed(() => ({ driverStoreActive: driverStoreActive.value, driverUpdateCount: showDriverStoreUpdateBadge.value, })); -provide(GROUP_TAB_BAR_PORTAL, createGroupTabBarPortal(computed(() => !isDetachedWindowContext && (driverStoreActive.value || pluginCenterActive.value || settingsStore.settingsPageActive)))); +provide(GROUP_TAB_BAR_PORTAL, createGroupTabBarPortal(isSpecialPageActive)); provide(EDITOR_TOOLBAR_ACTIONS, { canNewQuery: canCreateNewQuery, newQuery: (groupId: string) => { @@ -1756,6 +1757,9 @@ function applyRightSidebarPanelState(next: RightSidebarPanelState) { } function setRightSidebarPanelOpen(panelId: RightSidebarPanelId, open: boolean) { + if (open && isSpecialPageActive.value) { + activateQuerySurface(); + } if ((panelId === "history" && !open) || (panelId !== "history" && open)) isHistoryPanelMaximized.value = false; if (panelId === "ai" && !open) { isAiPanelMaximized.value = false; @@ -3644,6 +3648,8 @@ function activateQueryTab(tabId: string): boolean { if (!queryStore.activateTab(tabId)) return false; activateQuerySurface(); pluginCenterActive.value = false; + isHistoryPanelMaximized.value = false; + isAiPanelMaximized.value = false; return true; } @@ -4478,7 +4484,7 @@ onUnmounted(() => {
@@ -4758,7 +4764,7 @@ onUnmounted(() => {
@@ -4787,9 +4793,9 @@ onUnmounted(() => {
@@ -4809,7 +4815,7 @@ onUnmounted(() => {
@@ -4823,7 +4829,7 @@ onUnmounted(() => {
diff --git a/apps/desktop/src/components/layout/__tests__/SpecialPageLayoutPanels.spec.ts b/apps/desktop/src/components/layout/__tests__/SpecialPageLayoutPanels.spec.ts new file mode 100644 index 0000000000..832e1ac3b4 --- /dev/null +++ b/apps/desktop/src/components/layout/__tests__/SpecialPageLayoutPanels.spec.ts @@ -0,0 +1,79 @@ +// @vitest-environment happy-dom +import { computed, ref } from "vue"; +import { describe, expect, it } from "vitest"; + +describe("Special page layout and right sidebar panels visibility", () => { + it("shows editor content and hides right panels when a special page is active", () => { + const isDetachedWindowContext = false; + const driverStoreActive = ref(false); + const pluginCenterActive = ref(false); + const settingsPageActive = ref(false); + const isAiPanelMaximized = ref(false); + const isHistoryPanelMaximized = ref(true); + const isZenMode = ref(false); + + const isSpecialPageActive = computed(() => !isDetachedWindowContext && (driverStoreActive.value || pluginCenterActive.value || settingsPageActive.value)); + + const showEditorContent = computed(() => isSpecialPageActive.value || (!isAiPanelMaximized.value && !isHistoryPanelMaximized.value) || isZenMode.value); + + const showAiPanelVisible = computed(() => !isSpecialPageActive.value && !isHistoryPanelMaximized.value && !isZenMode.value); + + const showHistoryPanelVisible = computed(() => !isSpecialPageActive.value && !isAiPanelMaximized.value && !isZenMode.value); + + const showSqlLibraryPanelVisible = computed(() => !isSpecialPageActive.value && !isAiPanelMaximized.value && !isHistoryPanelMaximized.value && !isZenMode.value); + + // Initially: query workspace, history is maximized + expect(isSpecialPageActive.value).toBe(false); + expect(showEditorContent.value).toBe(false); // editor content hidden because history is maximized + expect(showHistoryPanelVisible.value).toBe(true); + + // User opens settings page + settingsPageActive.value = true; + expect(isSpecialPageActive.value).toBe(true); + // Settings page in editor content must be visible even if history was maximized + expect(showEditorContent.value).toBe(true); + // Right sidebar panels must be hidden on settings page + expect(showHistoryPanelVisible.value).toBe(false); + expect(showAiPanelVisible.value).toBe(false); + expect(showSqlLibraryPanelVisible.value).toBe(false); + + // User closes settings and returns to query editor + settingsPageActive.value = false; + expect(isSpecialPageActive.value).toBe(false); + expect(showEditorContent.value).toBe(false); // back to maximized history + expect(showHistoryPanelVisible.value).toBe(true); + }); + + it("switches to query surface if a right sidebar panel is toggled from a special page", () => { + const surface = ref("settings"); + const isSpecialPageActive = computed(() => surface.value === "settings"); + + function activateQuerySurface() { + surface.value = "query"; + } + + function setRightSidebarPanelOpen(open: boolean) { + if (open && isSpecialPageActive.value) { + activateQuerySurface(); + } + } + + setRightSidebarPanelOpen(true); + expect(surface.value).toBe("query"); + expect(isSpecialPageActive.value).toBe(false); + }); + + it("resets maximized panel state when an ordinary query tab is activated", () => { + const isHistoryPanelMaximized = ref(true); + const isAiPanelMaximized = ref(true); + + function activateQueryTab() { + isHistoryPanelMaximized.value = false; + isAiPanelMaximized.value = false; + } + + activateQueryTab(); + expect(isHistoryPanelMaximized.value).toBe(false); + expect(isAiPanelMaximized.value).toBe(false); + }); +});