mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-02 04:12:47 +02:00
feat(filesystem): enhance local file handling in editor and IPC integration
This commit is contained in:
parent
4899588cd7
commit
864f6f798a
12 changed files with 350 additions and 47 deletions
44
surfsense_web/lib/agent-filesystem.ts
Normal file
44
surfsense_web/lib/agent-filesystem.ts
Normal 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",
|
||||
};
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue