fix: restore desktop window dragging on remote instances
- Fixes header drag behavior in Desktop when connected to remote hosts - Routes all window-drag entry points through a shared safe desktop helper - Keeps local desktop drag behavior unchanged while avoiding remote IPC failures
This commit is contained in:
@@ -62,7 +62,7 @@ import type { SessionContextUsage } from '@/stores/types/sessionTypes';
|
|||||||
import { DesktopHostSwitcherDialog } from '@/components/desktop/DesktopHostSwitcher';
|
import { DesktopHostSwitcherDialog } from '@/components/desktop/DesktopHostSwitcher';
|
||||||
import { OpenInAppButton } from '@/components/desktop/OpenInAppButton';
|
import { OpenInAppButton } from '@/components/desktop/OpenInAppButton';
|
||||||
import { ProjectActionsButton } from '@/components/layout/ProjectActionsButton';
|
import { ProjectActionsButton } from '@/components/layout/ProjectActionsButton';
|
||||||
import { isDesktopShell, isVSCodeRuntime } from '@/lib/desktop';
|
import { isDesktopShell, isVSCodeRuntime, startDesktopWindowDrag } from '@/lib/desktop';
|
||||||
import { desktopHostsGet, locationMatchesHost, redactSensitiveUrl } from '@/lib/desktopHosts';
|
import { desktopHostsGet, locationMatchesHost, redactSensitiveUrl } from '@/lib/desktopHosts';
|
||||||
import { resolveSessionDiffStats } from '@/components/session/sidebar/utils';
|
import { resolveSessionDiffStats } from '@/components/session/sidebar/utils';
|
||||||
import type { Session } from '@opencode-ai/sdk/v2/client';
|
import type { Session } from '@opencode-ai/sdk/v2/client';
|
||||||
@@ -1405,13 +1405,7 @@ export const Header: React.FC<HeaderProps> = ({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isDesktopApp) {
|
if (isDesktopApp) {
|
||||||
try {
|
await startDesktopWindowDrag();
|
||||||
const { getCurrentWindow } = await import('@tauri-apps/api/window');
|
|
||||||
const window = getCurrentWindow();
|
|
||||||
await window.startDragging();
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Failed to start window dragging:', error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, [isDesktopApp]);
|
}, [isDesktopApp]);
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@/lib/utils';
|
||||||
import { useUIStore } from '@/stores/useUIStore';
|
import { useUIStore } from '@/stores/useUIStore';
|
||||||
import { isDesktopShell } from '@/lib/desktop';
|
import { isDesktopShell, startDesktopWindowDrag } from '@/lib/desktop';
|
||||||
|
|
||||||
export const RIGHT_SIDEBAR_CONTENT_WIDTH = 420;
|
export const RIGHT_SIDEBAR_CONTENT_WIDTH = 420;
|
||||||
const RIGHT_SIDEBAR_MIN_WIDTH = 400;
|
const RIGHT_SIDEBAR_MIN_WIDTH = 400;
|
||||||
@@ -123,13 +123,7 @@ export const RightSidebar: React.FC<RightSidebarProps> = ({ isOpen, children, cl
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
await startDesktopWindowDrag();
|
||||||
const { getCurrentWindow } = await import('@tauri-apps/api/window');
|
|
||||||
const appWindow = getCurrentWindow();
|
|
||||||
await appWindow.startDragging();
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Failed to start window dragging:', error);
|
|
||||||
}
|
|
||||||
}, [isDesktopApp]);
|
}, [isDesktopApp]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import type { CreateMultiRunParams, MultiRunModelSelection } from '@/types/multi
|
|||||||
import { ModelMultiSelect, generateInstanceId, type ModelSelectionWithId } from './ModelMultiSelect';
|
import { ModelMultiSelect, generateInstanceId, type ModelSelectionWithId } from './ModelMultiSelect';
|
||||||
import { BranchSelector, useBranchOptions } from './BranchSelector';
|
import { BranchSelector, useBranchOptions } from './BranchSelector';
|
||||||
import { AgentSelector } from './AgentSelector';
|
import { AgentSelector } from './AgentSelector';
|
||||||
import { isDesktopShell } from '@/lib/desktop';
|
import { isDesktopShell, startDesktopWindowDrag } from '@/lib/desktop';
|
||||||
import { useThemeSystem } from '@/contexts/useThemeSystem';
|
import { useThemeSystem } from '@/contexts/useThemeSystem';
|
||||||
import { PROJECT_ICON_MAP, PROJECT_COLOR_MAP, getProjectIconImageUrl } from '@/lib/projectMeta';
|
import { PROJECT_ICON_MAP, PROJECT_COLOR_MAP, getProjectIconImageUrl } from '@/lib/projectMeta';
|
||||||
import type { ProjectEntry } from '@/lib/api/types';
|
import type { ProjectEntry } from '@/lib/api/types';
|
||||||
@@ -266,13 +266,7 @@ export const MultiRunLauncher: React.FC<MultiRunLauncherProps> = ({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isDesktopApp) {
|
if (isDesktopApp) {
|
||||||
try {
|
await startDesktopWindowDrag();
|
||||||
const { getCurrentWindow } = await import('@tauri-apps/api/window');
|
|
||||||
const window = getCurrentWindow();
|
|
||||||
await window.startDragging();
|
|
||||||
} catch {
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, [isDesktopApp]);
|
}, [isDesktopApp]);
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { RiFileCopyLine, RiCheckLine, RiExternalLinkLine } from '@remixicon/react';
|
import { RiFileCopyLine, RiCheckLine, RiExternalLinkLine } from '@remixicon/react';
|
||||||
import { isDesktopShell, isTauriShell } from '@/lib/desktop';
|
import { isDesktopShell, isTauriShell, startDesktopWindowDrag } from '@/lib/desktop';
|
||||||
import { Input } from '@/components/ui/input';
|
import { Input } from '@/components/ui/input';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { updateDesktopSettings } from '@/lib/persistence';
|
import { updateDesktopSettings } from '@/lib/persistence';
|
||||||
@@ -105,14 +105,8 @@ export function OnboardingScreen({ onCliAvailable }: OnboardingScreenProps) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (e.button !== 0) return;
|
if (e.button !== 0) return;
|
||||||
if (isDesktopApp && isTauriShell()) {
|
if (isDesktopApp) {
|
||||||
try {
|
await startDesktopWindowDrag();
|
||||||
const { getCurrentWindow } = await import('@tauri-apps/api/window');
|
|
||||||
const window = getCurrentWindow();
|
|
||||||
await window.startDragging();
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Failed to start window dragging:', error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, [isDesktopApp]);
|
}, [isDesktopApp]);
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import type { Session } from '@opencode-ai/sdk/v2';
|
|||||||
import { RiLayoutLeftLine } from '@remixicon/react';
|
import { RiLayoutLeftLine } from '@remixicon/react';
|
||||||
import { toast } from '@/components/ui';
|
import { toast } from '@/components/ui';
|
||||||
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';
|
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';
|
||||||
import { isDesktopLocalOriginActive, isDesktopShell, isTauriShell } from '@/lib/desktop';
|
import { isDesktopLocalOriginActive, isDesktopShell, isTauriShell, startDesktopWindowDrag } from '@/lib/desktop';
|
||||||
import { MobileOverlayPanel } from '@/components/ui/MobileOverlayPanel';
|
import { MobileOverlayPanel } from '@/components/ui/MobileOverlayPanel';
|
||||||
import { sessionEvents } from '@/lib/sessionEvents';
|
import { sessionEvents } from '@/lib/sessionEvents';
|
||||||
import { formatDirectoryName, cn } from '@/lib/utils';
|
import { formatDirectoryName, cn } from '@/lib/utils';
|
||||||
@@ -490,13 +490,7 @@ export const SessionSidebar: React.FC<SessionSidebarProps> = ({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
await startDesktopWindowDrag();
|
||||||
const { getCurrentWindow } = await import('@tauri-apps/api/window');
|
|
||||||
const appWindow = getCurrentWindow();
|
|
||||||
await appWindow.startDragging();
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Failed to start window dragging:', error);
|
|
||||||
}
|
|
||||||
}, [isDesktopShellRuntime]);
|
}, [isDesktopShellRuntime]);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
|||||||
@@ -242,6 +242,21 @@ export const isDesktopShell = (): boolean => {
|
|||||||
return isTauriShell();
|
return isTauriShell();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const startDesktopWindowDrag = async (): Promise<boolean> => {
|
||||||
|
if (!isDesktopShell() || !isTauriShell()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const { getCurrentWindow } = await import('@tauri-apps/api/window');
|
||||||
|
const appWindow = getCurrentWindow();
|
||||||
|
await appWindow.startDragging();
|
||||||
|
return true;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export const isVSCodeRuntime = (): boolean => {
|
export const isVSCodeRuntime = (): boolean => {
|
||||||
if (typeof window === "undefined") return false;
|
if (typeof window === "undefined") return false;
|
||||||
const apis = (window as { __OPENCHAMBER_RUNTIME_APIS__?: { runtime?: { isVSCode?: boolean } } }).__OPENCHAMBER_RUNTIME_APIS__;
|
const apis = (window as { __OPENCHAMBER_RUNTIME_APIS__?: { runtime?: { isVSCode?: boolean } } }).__OPENCHAMBER_RUNTIME_APIS__;
|
||||||
|
|||||||
Reference in New Issue
Block a user