feat(settings): configure SQL file size limits

This commit is contained in:
t8y2 authored and GitHub committed 2026-09-08 19:42:32 +08:00
1 parent 9a0e3e744c
commit 39e34d44f7
34 files changed
+554 -79

No files matched your search

+2
View File
@@ -313,6 +313,8 @@ export const saveDesktopSettings = forward("saveDesktopSettings");
export const loadMcpGlobalPolicy = forward("loadMcpGlobalPolicy");
export const saveMcpGlobalPolicy = forward("saveMcpGlobalPolicy");
export const loadMaxAgentTurns = forward("loadMaxAgentTurns");
export const loadSqlFileUploadMaxBytes = forward("loadSqlFileUploadMaxBytes");
export const saveSqlFileUploadMaxMb = forward("saveSqlFileUploadMaxMb");
export const saveMaxAgentTurns = forward("saveMaxAgentTurns");
export const loadMaxRetries = forward("loadMaxRetries");
export const saveMaxRetries = forward("saveMaxRetries");
+15 -2
View File
@@ -1848,6 +1848,19 @@ export async function loadMaxAgentTurns(): Promise<number> {
return get("/api/app-settings/max-agent-turns");
}
export async function loadSqlFileUploadMaxBytes(): Promise<number> {
return get("/api/app-settings/sql-file-upload-max-bytes");
}
export async function saveSqlFileUploadMaxMb(sqlFileUploadMaxMb: number): Promise<void> {
const res = await fetch(apiUrl("/api/app-settings/sql-file-upload-max-bytes"), {
method: "PUT",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ sqlFileUploadMaxMb }),
});
if (!res.ok) throw await backendResponseError(res);
}
export async function saveMaxAgentTurns(maxAgentTurns: number): Promise<void> {
const res = await fetch(apiUrl("/api/app-settings/max-agent-turns"), {
method: "PUT",
@@ -2270,11 +2283,11 @@ export async function pendingOpenAiConfigLinks(): Promise<string[]> {
return [];
}
export async function readExternalSqlFile(_path: string): Promise<string> {
export async function readExternalSqlFile(_path: string, _maxSizeBytes?: number): Promise<string> {
throw new Error("Opening external SQL file paths is only available in the desktop app");
}
export async function readExternalSqlFileSnapshot(_path: string): Promise<import("@/lib/backend/tauri").ExternalSqlFileSnapshot> {
export async function readExternalSqlFileSnapshot(_path: string, _maxSizeBytes?: number): Promise<import("@/lib/backend/tauri").ExternalSqlFileSnapshot> {
throw new Error("Opening external SQL file paths is only available in the desktop app");
}
+12 -4
View File
@@ -717,6 +717,14 @@ export async function loadMaxAgentTurns(): Promise<number> {
return invoke("load_max_agent_turns");
}
export async function loadSqlFileUploadMaxBytes(): Promise<number> {
return 200 * 1024 * 1024;
}
export async function saveSqlFileUploadMaxMb(_sqlFileUploadMaxMb: number): Promise<void> {
// No-op on desktop: SQL files are streamed directly from disk, no server upload cap applies.
}
export async function saveMaxAgentTurns(maxAgentTurns: number): Promise<void> {
return invoke("save_max_agent_turns", { maxAgentTurns });
}
@@ -970,16 +978,16 @@ export type ExternalSqlFileStatus = { kind: "present"; sizeBytes: number; modifi
export type ExternalSqlFileWriteResult = { kind: "written"; version: ExternalSqlFileVersion } | { kind: "conflict"; currentVersion: ExternalSqlFileVersion } | { kind: "missing" };
export async function readExternalSqlFileSnapshot(path: string): Promise<ExternalSqlFileSnapshot> {
const result = await invoke<{ kind: "content"; content: string; version: ExternalSqlFileVersion } | { kind: "tooLarge"; sizeBytes: number; maxSizeBytes: number }>("read_external_sql_file", { path });
export async function readExternalSqlFileSnapshot(path: string, maxSizeBytes?: number): Promise<ExternalSqlFileSnapshot> {
const result = await invoke<{ kind: "content"; content: string; version: ExternalSqlFileVersion } | { kind: "tooLarge"; sizeBytes: number; maxSizeBytes: number }>("read_external_sql_file", { path, maxSizeBytes });
if (result.kind === "tooLarge") {
throw new ExternalSqlFileTooLargeError(result.sizeBytes, result.maxSizeBytes);
}
return { content: result.content, version: result.version };
}
export async function readExternalSqlFile(path: string): Promise<string> {
return (await readExternalSqlFileSnapshot(path)).content;
export async function readExternalSqlFile(path: string, maxSizeBytes?: number): Promise<string> {
return (await readExternalSqlFileSnapshot(path, maxSizeBytes)).content;
}
export async function inspectExternalSqlFile(path: string): Promise<ExternalSqlFileStatus> {