Files
cc-switch/src/lib/api/sessions.ts
Alexlangl 8e2ffbc845 feat: add bulk delete for session manager (#1693)
* feat: add bulk delete for session manager

* fix: address batch delete review issues

* fix: keep session list in sync after batch delete
2026-03-30 22:15:57 +08:00

55 lines
1.3 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 interface DeleteSessionResult extends DeleteSessionOptions {
success: boolean;
error?: 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 deleteMany(
items: DeleteSessionOptions[],
): Promise<DeleteSessionResult[]> {
return await invoke("delete_sessions", { items });
},
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,
});
},
};