mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-27 08:14:33 +08:00
8c3f18a9bd
Add delete_session Tauri command dispatching to provider-specific deletion logic for all 5 providers (Claude, Codex, Gemini, OpenCode, OpenClaw). Includes path traversal protection via canonicalize + starts_with validation, session ID verification against file contents, frontend confirmation dialog with optimistic cache updates, i18n keys (zh/en/ja), and component tests.
44 lines
1.0 KiB
TypeScript
44 lines
1.0 KiB
TypeScript
import { invoke } from "@tauri-apps/api/core";
|
|
import type { SessionMessage, SessionMeta } from "@/types";
|
|
|
|
export interface DeleteSessionOptions {
|
|
providerId: string;
|
|
sessionId: string;
|
|
sourcePath: string;
|
|
}
|
|
|
|
export const sessionsApi = {
|
|
async list(): Promise<SessionMeta[]> {
|
|
return await invoke("list_sessions");
|
|
},
|
|
|
|
async getMessages(
|
|
providerId: string,
|
|
sourcePath: string,
|
|
): Promise<SessionMessage[]> {
|
|
return await invoke("get_session_messages", { providerId, sourcePath });
|
|
},
|
|
|
|
async delete(options: DeleteSessionOptions): Promise<boolean> {
|
|
const { providerId, sessionId, sourcePath } = options;
|
|
return await invoke("delete_session", {
|
|
providerId,
|
|
sessionId,
|
|
sourcePath,
|
|
});
|
|
},
|
|
|
|
async launchTerminal(options: {
|
|
command: string;
|
|
cwd?: string | null;
|
|
customConfig?: string | null;
|
|
}): Promise<boolean> {
|
|
const { command, cwd, customConfig } = options;
|
|
return await invoke("launch_session_terminal", {
|
|
command,
|
|
cwd,
|
|
customConfig,
|
|
});
|
|
},
|
|
};
|