refactor: setup sidebar workspace and session list

This commit is contained in:
Haileyesus
2026-03-30 15:48:20 +03:00
parent e165d2ca24
commit dfe9c75cfd
22 changed files with 2217 additions and 81 deletions

View File

@@ -16,6 +16,25 @@ export const workspaceOriginalPathsDb = {
`).run(workspacePath, customWorkspaceName);
},
getWorkspacePath(workspacePath: string): WorkspaceOriginalPathRow | null {
const db = getConnection();
const row = db.prepare(`
SELECT workspace_path, custom_workspace_name, isStarred
FROM workspace_original_paths
WHERE workspace_path = ?
`).get(workspacePath) as WorkspaceOriginalPathRow | undefined;
return row ?? null;
},
getWorkspacePaths(): WorkspaceOriginalPathRow[] {
const db = getConnection();
return db.prepare(`
SELECT workspace_path, custom_workspace_name, isStarred
FROM workspace_original_paths
`).all() as WorkspaceOriginalPathRow[];
},
getCustomWorkspaceName(workspacePath: string): string | null {
const db = getConnection();
const row = db.prepare(`
@@ -35,4 +54,21 @@ export const workspaceOriginalPathsDb = {
ON CONFLICT(workspace_path) DO UPDATE SET custom_workspace_name = excluded.custom_workspace_name
`).run(workspacePath, customWorkspaceName);
},
updateWorkspaceIsStarred(workspacePath: string, isStarred: boolean): void {
const db = getConnection();
db.prepare(`
UPDATE workspace_original_paths
SET isStarred = ?
WHERE workspace_path = ?
`).run(isStarred ? 1 : 0, workspacePath);
},
deleteWorkspacePath(workspacePath: string): void {
const db = getConnection();
db.prepare(`
DELETE FROM workspace_original_paths
WHERE workspace_path = ?
`).run(workspacePath);
},
};