Avoid broadcasting remote image paste paths (#1410)
This commit is contained in:
@@ -28,7 +28,7 @@ test("remote paths are quoted for shell-safe insertion", () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("remote clipboard image paste uploads and inserts the remote image path", async () => {
|
test("remote clipboard image paste uploads and inserts the remote image path without broadcasting", async () => {
|
||||||
const writes: Array<{ sessionId: string; data: string }> = [];
|
const writes: Array<{ sessionId: string; data: string }> = [];
|
||||||
const scrolled: string[] = [];
|
const scrolled: string[] = [];
|
||||||
let focused = false;
|
let focused = false;
|
||||||
@@ -67,7 +67,6 @@ test("remote clipboard image paste uploads and inserts the remote image path", a
|
|||||||
terminalBackend: {
|
terminalBackend: {
|
||||||
writeToSession: (sessionId, data) => writes.push({ sessionId, data }),
|
writeToSession: (sessionId, data) => writes.push({ sessionId, data }),
|
||||||
},
|
},
|
||||||
onPasteData: (data) => broadcastData.push(data),
|
|
||||||
term: {
|
term: {
|
||||||
focus: () => {
|
focus: () => {
|
||||||
focused = true;
|
focused = true;
|
||||||
@@ -95,7 +94,7 @@ test("remote clipboard image paste uploads and inserts the remote image path", a
|
|||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
assert.deepEqual(scrolled, ["/home/alice/project/.netcatty-paste-images/shot_1.png"]);
|
assert.deepEqual(scrolled, ["/home/alice/project/.netcatty-paste-images/shot_1.png"]);
|
||||||
assert.deepEqual(broadcastData, ["/home/alice/project/.netcatty-paste-images/shot_1.png"]);
|
assert.deepEqual(broadcastData, []);
|
||||||
assert.equal(focused, true);
|
assert.equal(focused, true);
|
||||||
assert.equal(closedSftpId, "sftp-1");
|
assert.equal(closedSftpId, "sftp-1");
|
||||||
assert.equal(deletedTempFile, "/tmp/netcatty/shot.png");
|
assert.equal(deletedTempFile, "/tmp/netcatty/shot.png");
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ type HandleRemoteClipboardImagePasteOptions = {
|
|||||||
createTransferId?: () => string;
|
createTransferId?: () => string;
|
||||||
getRemoteCwd: () => Promise<string | null | undefined>;
|
getRemoteCwd: () => Promise<string | null | undefined>;
|
||||||
scrollToBottomAfterProgrammaticInput?: (data: string) => void;
|
scrollToBottomAfterProgrammaticInput?: (data: string) => void;
|
||||||
onPasteData?: (data: string) => boolean | void;
|
|
||||||
sessionId: string | null | undefined;
|
sessionId: string | null | undefined;
|
||||||
terminalBackend: {
|
terminalBackend: {
|
||||||
writeToSession: (sessionId: string, data: string, options?: { automated?: boolean }) => void;
|
writeToSession: (sessionId: string, data: string, options?: { automated?: boolean }) => void;
|
||||||
@@ -71,7 +70,6 @@ export async function handleRemoteClipboardImagePaste({
|
|||||||
createTransferId = defaultTransferId,
|
createTransferId = defaultTransferId,
|
||||||
getRemoteCwd,
|
getRemoteCwd,
|
||||||
scrollToBottomAfterProgrammaticInput,
|
scrollToBottomAfterProgrammaticInput,
|
||||||
onPasteData,
|
|
||||||
sessionId,
|
sessionId,
|
||||||
terminalBackend,
|
terminalBackend,
|
||||||
term,
|
term,
|
||||||
@@ -105,7 +103,6 @@ export async function handleRemoteClipboardImagePaste({
|
|||||||
|
|
||||||
const pastedPath = quoteRemotePathForShell(targetPath);
|
const pastedPath = quoteRemotePathForShell(targetPath);
|
||||||
terminalBackend.writeToSession(sessionId, pastedPath);
|
terminalBackend.writeToSession(sessionId, pastedPath);
|
||||||
onPasteData?.(pastedPath);
|
|
||||||
scrollToBottomAfterProgrammaticInput?.(pastedPath);
|
scrollToBottomAfterProgrammaticInput?.(pastedPath);
|
||||||
term?.focus?.();
|
term?.focus?.();
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -85,7 +85,6 @@ export const useTerminalContextActions = ({
|
|||||||
sessionId: sessionRef.current,
|
sessionId: sessionRef.current,
|
||||||
terminalBackend,
|
terminalBackend,
|
||||||
term,
|
term,
|
||||||
onPasteData: broadcastUserPasteData,
|
|
||||||
scrollToBottomAfterProgrammaticInput,
|
scrollToBottomAfterProgrammaticInput,
|
||||||
});
|
});
|
||||||
if (handled) return;
|
if (handled) return;
|
||||||
|
|||||||
@@ -74,7 +74,6 @@ export function useTerminalFilePaste({
|
|||||||
sessionId: sessionRef.current,
|
sessionId: sessionRef.current,
|
||||||
terminalBackend,
|
terminalBackend,
|
||||||
term: termRef.current,
|
term: termRef.current,
|
||||||
onPasteData,
|
|
||||||
scrollToBottomAfterProgrammaticInput,
|
scrollToBottomAfterProgrammaticInput,
|
||||||
});
|
});
|
||||||
if (!handled) fallbackToTextPaste();
|
if (!handled) fallbackToTextPaste();
|
||||||
|
|||||||
Reference in New Issue
Block a user