Files
openidea/src/platform/nativeDrop.ts
l0ng-ai 5f57ce962e fix(project): import local files into remote project trees (#587)
Pasting or dropping OS files into a remote project tree sent a client-local source path to the server, so nothing was copied. Local-source imports are now carried separately from project copies and uploaded over the session SFTP channel: streamed in bounded chunks, created exclusively, cancellable across all selected paths under one task, with partial files removed on failure. Symlinks and Unix file modes are preserved, and special files are skipped and reported. Project-internal paste keeps working when the OS clipboard is briefly unavailable.

Native drop positions were assumed to be physical pixels, which shifted the target far from the pointer on Retina displays and with IDE zoom. A shared helper converts them to CSS coordinates for the project tree, the editor and Markdown drop handling, and the agent composer. Composer image drops are now read on the client in remote windows.

Verified on macOS against a live SSH host. Windows and Linux were not run: the Windows conversion is unchanged, the Linux one changed. Copy out from a remote tree to the local machine still needs a download workflow.
2026-11-01 00:14:56 +08:00

22 lines
656 B
TypeScript

import { usePlatform } from "./platformInfo";
import { useProject } from "./project";
import { clampZoom } from "./zoom";
interface Point {
x: number;
y: number;
}
/** Wry Cocoa/GTK supply logical points; Win32 supplies physical client pixels.
* WebView2's DPR includes zoom; WKWebView's does not. All consumers need CSS pixels.
*/
export function nativeDropPoint(
point: Point,
os = usePlatform.getState().os,
dpr = window.devicePixelRatio || 1,
zoom = clampZoom(useProject.getState().settings?.appearance?.zoom) / 100,
): Point {
const divisor = os === "windows" ? dpr : zoom;
return { x: point.x / divisor, y: point.y / divisor };
}