Files
openidea/src/features/deployment/windowBridge.ts
T
Mariano Dupontandmarianomd b31938db00 feat(deployment): add standalone comparison and selected-file sync (#1070)
Sync with Deployed opens in its own window, one per project window. It lists local files next to the server's copies, with filters, content and binary comparison, and an embedded side-by-side diff whose local side can be edited. The selected file can be synchronized (Enter) without closing the window.

The window is the `deployment` kind of the auxiliary windows that Settings and comparisons use. A cancelled close in it stops its project window from closing. The preview uses the vcs diff viewer through its `diff` editor kind. Also covers #811 (compare with the deployed versions).

Co-authored-by: marianomd <[email protected]>
2026-11-04 12:40:45 +08:00

41 lines
1.5 KiB
TypeScript

import { emitTo } from "@tauri-apps/api/event";
import { getCurrentWebviewWindow } from "@tauri-apps/api/webviewWindow";
import { call, commands, isTauri } from "@/platform/ipc";
import { useProject } from "@/platform/project";
import { editorService, type OpenOptions } from "@/workbench/contributions";
import { windowBackgroundHex } from "@/workbench/theme";
const OPEN_SOURCE = "openidea://deployment/open-source";
export function showDeploymentComparison(server: string, paths: string[]) {
return call(commands.windowOpenDeployment(server, paths, windowBackgroundHex()));
}
export function openDeploymentSource(parent: string, path: string, options?: OpenOptions) {
return emitTo(parent, OPEN_SOURCE, { path, options });
}
/** Jump to Source from the comparison opens the local file in its project's editor. */
export function installDeploymentEditorHost(): () => void {
if (!isTauri()) return () => {};
let disposed = false;
let unlisten: (() => void) | undefined;
void getCurrentWebviewWindow()
.listen<{ path: string; options?: OpenOptions }>(OPEN_SOURCE, ({ payload }) => {
const root = useProject.getState().project?.root;
if (root && payload.path.startsWith(`${root}/`)) {
void editorService()
.openFile(payload.path, payload.options)
.then(() => getCurrentWebviewWindow().setFocus());
}
})
.then((off) => {
if (disposed) off();
else unlisten = off;
});
return () => {
disposed = true;
unlisten?.();
};
}