feat(filesystem): enhance local file handling in editor and IPC integration

This commit is contained in:
Anish Sarkar 2026-04-23 17:23:38 +05:30
parent 4899588cd7
commit 864f6f798a
12 changed files with 350 additions and 47 deletions

View file

@ -0,0 +1,44 @@
export type AgentFilesystemMode = "cloud" | "desktop_local_folder";
export type ClientPlatform = "web" | "desktop";
export interface AgentFilesystemSelection {
filesystem_mode: AgentFilesystemMode;
client_platform: ClientPlatform;
local_filesystem_root?: string;
}
const DEFAULT_SELECTION: AgentFilesystemSelection = {
filesystem_mode: "cloud",
client_platform: "web",
};
export function getClientPlatform(): ClientPlatform {
if (typeof window === "undefined") return "web";
return window.electronAPI ? "desktop" : "web";
}
export async function getAgentFilesystemSelection(): Promise<AgentFilesystemSelection> {
const platform = getClientPlatform();
if (platform !== "desktop" || !window.electronAPI?.getAgentFilesystemSettings) {
return { ...DEFAULT_SELECTION, client_platform: platform };
}
try {
const settings = await window.electronAPI.getAgentFilesystemSettings();
if (settings.mode === "desktop_local_folder" && settings.localRootPath) {
return {
filesystem_mode: "desktop_local_folder",
client_platform: "desktop",
local_filesystem_root: settings.localRootPath,
};
}
return {
filesystem_mode: "cloud",
client_platform: "desktop",
};
} catch {
return {
filesystem_mode: "cloud",
client_platform: "desktop",
};
}
}