mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-05-07 06:07:18 +08:00
* feat: add bulk delete for session manager * fix: address batch delete review issues * fix: keep session list in sync after batch delete
55 lines
1.3 KiB
TypeScript
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,
|
|
});
|
|
},
|
|
};
|