Порівняти коміти

...
Автор SHA1 Повідомлення Дата
l0ng-ai 30d68591fc fix(project-tree): name a file dropped from Windows by its file name
Tauri reports dropped files on Windows as `E:\\dir\\file`, and the import named the
copy from `/`-separated paths, so a file dropped into an SSH remote project was uploaded
as `E:\\dir\\file`. Dropped paths are normalized to the UI's `/` form first; the
welcome screen's open-on-drop and the agent composer's attachments do the same.

Fixes #7171
2026-12-01 16:18:34 +08:00
4 змінених файлів з 17 додано та 2 видалено

No files matched your search

+2 -1
Переглянути файл
@@ -91,6 +91,7 @@ import { imageSrc } from "./imageActions";
import { useAgentSettings } from "./agentSettings";
import styles from "./Composer.module.css";
import { isImeKey } from "@/platform/ime";
import { ipcPath } from "@/platform/paths";
const MAX_ITEMS = 12;
const MAX_OPEN_EDITORS = 5;
@@ -1063,7 +1064,7 @@ export function Composer(props: ComposerProps) {
setFileOver(false);
if (p.type !== "drop" || !p.paths.length || !inBox(p.position)) return;
const paths: string[] = [];
for (const path of p.paths) {
for (const path of p.paths.map(ipcPath)) {
if (IMAGE_EXTENSIONS.test(path)) {
void invokeLocal<string>("fs_read_image", { path }).then(
(url) => {
+10
Переглянути файл
@@ -352,6 +352,16 @@ describe("OS file imports", () => {
expect(notify).not.toHaveBeenCalled();
});
it("names a file dropped from Windows by its file name, not its whole path", async () => {
const imported = vi.spyOn(fs, "importLocal").mockResolvedValueOnce([]);
await importExternal(["E:\\Users\\me\\Downloads\\gdb-18.1.tar.gz"], "/p/target");
expect(imported).toHaveBeenCalledWith(
"E:/Users/me/Downloads/gdb-18.1.tar.gz",
"/p/target/gdb-18.1.tar.gz",
expect.anything(),
);
});
it("reports skipped entries while keeping the imported folder", async () => {
vi.spyOn(fs, "importLocal").mockResolvedValueOnce(["bundle/pipe: skipped special file"]);
expect(await transfer(["/bundle"], "/p/target", "copy", undefined, "local")).toBe("/p/target/bundle");
+3
Переглянути файл
@@ -23,6 +23,7 @@ import { renameCopiedJavaType } from "./javaCopy";
import { javaPackageAt, pastedJavaClass, withJavaPackage } from "./javaPaste";
import { currentRoots } from "@/platform/projectRoots";
import { notifyFileOperation } from "@/platform/fileOps";
import { ipcPath } from "@/platform/paths";
import { IpcError, isCancelled, isTauri } from "@/platform/ipc";
import { MEMBER_PREFIX, type ProjectNode } from "./model";
import {
@@ -1015,6 +1016,8 @@ export async function dropPaths(paths: string[], target: string, copy: boolean)
export async function importExternal(paths: string[], target: string) {
const { root } = get();
if (!root || !paths.length || isReadOnlyPath(target)) return;
// The OS reports Windows paths as `E:\\dir\\file`; entries are named from `/`-separated paths.
paths = paths.map(ipcPath);
if (isRemoteWindow()) return void (await transfer(paths, target, "copy", undefined, "local"));
const inside = paths.filter((p) => isSameOrInside(p, root));
const outside = paths.filter((p) => !isSameOrInside(p, root));
+2 -1
Переглянути файл
@@ -16,6 +16,7 @@ import { ProjectsPage } from "./ProjectsPage";
import { loadRecent, useRecent } from "./recent";
import { cancelReopen, useSession } from "./session";
import styles from "./Welcome.module.css";
import { ipcPath } from "@/platform/paths";
export type WelcomePage = "projects" | "customize" | "plugins";
@@ -102,7 +103,7 @@ function useFolderDrop(): boolean {
setOver(false);
const { project, lightEdit } = useProject.getState();
if (p.type === "drop" && p.paths.length && !project && !lightEdit)
void executeAction("file.openPaths", p.paths);
void executeAction("file.openPaths", p.paths.map(ipcPath));
})
.then((u) => {
if (disposed) u();