From eaa940ab90d754a482c16aaa1c0a34871d2bbb12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=91=98=E9=98=BF=E6=B1=9F=28Relakkes?= =?UTF-8?q?=29?= Date: Wed, 3 Jun 2026 16:37:28 +0800 Subject: [PATCH] fix(desktop): restore sidebar titlebar dragging The sidebar title area also needs to participate in Electron's CSS app-region chrome. Mark only the sidebar title/header region as draggable and keep the full sidebar body out of the drag region so session rows, search controls, and project actions remain normal interactions. Constraint: Electron window dragging is driven by CSS app-region regions after the migration Rejected: Keep the sidebar-wide startDragging mouse handler | Electron does not use that as the active drag path and it misses the left title gap Confidence: high Scope-risk: narrow Directive: Keep sidebar body interactions outside the drag region unless a real titlebar affordance is added there Tested: cd desktop && bun run test src/components/layout/Sidebar.test.tsx --run Tested: bun run check:desktop --- .../src/components/layout/Sidebar.test.tsx | 1 + desktop/src/components/layout/Sidebar.tsx | 21 +++++-------------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/desktop/src/components/layout/Sidebar.test.tsx b/desktop/src/components/layout/Sidebar.test.tsx index 5fe96033..55fdc2b8 100644 --- a/desktop/src/components/layout/Sidebar.test.tsx +++ b/desktop/src/components/layout/Sidebar.test.tsx @@ -255,6 +255,7 @@ describe('Sidebar', () => { ]) expect(useTabStore.getState().activeTabId).toBe('session-new-1') expect(screen.getByRole('complementary')).not.toHaveAttribute('data-desktop-drag-region') + expect(screen.getByTestId('sidebar-title-region')).toHaveAttribute('data-desktop-drag-region') }) it('groups sessions by project and expands overflow rows', () => { diff --git a/desktop/src/components/layout/Sidebar.tsx b/desktop/src/components/layout/Sidebar.tsx index d41ad1fb..1a6bc7e5 100644 --- a/desktop/src/components/layout/Sidebar.tsx +++ b/desktop/src/components/layout/Sidebar.tsx @@ -15,7 +15,6 @@ import { publicAssetPath } from '../../lib/publicAsset' const desktopHost = getDesktopHost() const isDesktopRuntime = desktopHost.isDesktop const canUseNativeDialogs = desktopHost.capabilities.dialogs -const canStartWindowDragging = desktopHost.capabilities.windowControls const isWindows = typeof navigator !== 'undefined' && /Win/.test(navigator.platform) const SESSION_LIST_AUTO_REFRESH_MS = 30_000 const SESSION_LIST_FOCUS_REFRESH_MIN_MS = 5_000 @@ -575,19 +574,6 @@ export function Sidebar({ isMobile = false, onRequestClose }: SidebarProps) { setRenameValue('') }, [renamingId, renameValue, renameSession]) - const startDraggingRef = useRef<(() => Promise) | null>(null) - - useEffect(() => { - if (!canStartWindowDragging) return - startDraggingRef.current = () => getDesktopHost().window.startDragging() - }, []) - - const handleSidebarDrag = useCallback((e: React.MouseEvent) => { - if (e.button !== 0) return - if ((e.target as HTMLElement).closest('button, input, textarea, select, a, [role="button"]')) return - startDraggingRef.current?.() - }, []) - useEffect(() => { if (!isBatchMode) return @@ -611,12 +597,15 @@ export function Sidebar({ isMobile = false, onRequestClose }: SidebarProps) { return (