// ======================================== // Workspace-Aware Query Keys Factory // ======================================== // TanStack Query key factory with projectPath prefix for cache isolation /** * Workspace-aware query keys factory * All keys include projectPath for cache isolation between workspaces */ export const workspaceQueryKeys = { // Base key that includes projectPath all: (projectPath: string) => ['workspace', projectPath] as const, // ========== Sessions ========== sessions: (projectPath: string) => [...workspaceQueryKeys.all(projectPath), 'sessions'] as const, sessionsList: (projectPath: string) => [...workspaceQueryKeys.sessions(projectPath), 'list'] as const, sessionDetail: (projectPath: string, sessionId: string) => [...workspaceQueryKeys.sessions(projectPath), 'detail', sessionId] as const, // ========== Tasks ========== tasks: (projectPath: string) => [...workspaceQueryKeys.all(projectPath), 'tasks'] as const, tasksList: (projectPath: string, sessionId: string) => [...workspaceQueryKeys.tasks(projectPath), 'list', sessionId] as const, taskDetail: (projectPath: string, taskId: string) => [...workspaceQueryKeys.tasks(projectPath), 'detail', taskId] as const, // ========== Loops ========== loops: (projectPath: string) => [...workspaceQueryKeys.all(projectPath), 'loops'] as const, loopsList: (projectPath: string) => [...workspaceQueryKeys.loops(projectPath), 'list'] as const, loopDetail: (projectPath: string, loopId: string) => [...workspaceQueryKeys.loops(projectPath), 'detail', loopId] as const, // ========== Issues ========== issues: (projectPath: string) => [...workspaceQueryKeys.all(projectPath), 'issues'] as const, issuesList: (projectPath: string) => [...workspaceQueryKeys.issues(projectPath), 'list'] as const, issuesHistory: (projectPath: string) => [...workspaceQueryKeys.issues(projectPath), 'history'] as const, issueQueue: (projectPath: string) => [...workspaceQueryKeys.issues(projectPath), 'queue'] as const, // ========== Memory ========== memory: (projectPath: string) => [...workspaceQueryKeys.all(projectPath), 'memory'] as const, memoryList: (projectPath: string) => [...workspaceQueryKeys.memory(projectPath), 'list'] as const, memoryDetail: (projectPath: string, memoryId: string) => [...workspaceQueryKeys.memory(projectPath), 'detail', memoryId] as const, // ========== Project Overview ========== projectOverview: (projectPath: string) => [...workspaceQueryKeys.all(projectPath), 'projectOverview'] as const, projectOverviewDetail: (projectPath: string) => [...workspaceQueryKeys.projectOverview(projectPath), 'detail'] as const, // ========== Lite Tasks ========== liteTasks: (projectPath: string) => [...workspaceQueryKeys.all(projectPath), 'liteTasks'] as const, liteTasksList: (projectPath: string, type?: 'lite-plan' | 'lite-fix' | 'multi-cli-plan') => [...workspaceQueryKeys.liteTasks(projectPath), 'list', type] as const, liteTaskDetail: (projectPath: string, sessionId: string) => [...workspaceQueryKeys.liteTasks(projectPath), 'detail', sessionId] as const, // ========== Review Sessions ========== reviewSessions: (projectPath: string) => [...workspaceQueryKeys.all(projectPath), 'reviewSessions'] as const, reviewSessionsList: (projectPath: string) => [...workspaceQueryKeys.reviewSessions(projectPath), 'list'] as const, reviewSessionDetail: (projectPath: string, sessionId: string) => [...workspaceQueryKeys.reviewSessions(projectPath), 'detail', sessionId] as const, // ========== Rules ========== rules: (projectPath: string) => [...workspaceQueryKeys.all(projectPath), 'rules'] as const, rulesList: (projectPath: string) => [...workspaceQueryKeys.rules(projectPath), 'list'] as const, // ========== Prompts ========== prompts: (projectPath: string) => [...workspaceQueryKeys.all(projectPath), 'prompts'] as const, promptsList: (projectPath: string) => [...workspaceQueryKeys.prompts(projectPath), 'list'] as const, promptsInsights: (projectPath: string) => [...workspaceQueryKeys.prompts(projectPath), 'insights'] as const, // ========== Index ========== index: (projectPath: string) => [...workspaceQueryKeys.all(projectPath), 'index'] as const, indexStatus: (projectPath: string) => [...workspaceQueryKeys.index(projectPath), 'status'] as const, // ========== File Explorer ========== explorer: (projectPath: string) => [...workspaceQueryKeys.all(projectPath), 'explorer'] as const, explorerTree: (projectPath: string, rootPath?: string) => [...workspaceQueryKeys.explorer(projectPath), 'tree', rootPath] as const, explorerFile: (projectPath: string, filePath?: string) => [...workspaceQueryKeys.explorer(projectPath), 'file', filePath] as const, // ========== Graph Explorer ========== graph: (projectPath: string) => [...workspaceQueryKeys.all(projectPath), 'graph'] as const, graphDependencies: (projectPath: string, options?: { maxDepth?: number }) => [...workspaceQueryKeys.graph(projectPath), 'dependencies', options] as const, graphImpact: (projectPath: string, nodeId: string) => [...workspaceQueryKeys.graph(projectPath), 'impact', nodeId] as const, // ========== CLI History ========== cliHistory: (projectPath: string) => [...workspaceQueryKeys.all(projectPath), 'cliHistory'] as const, cliHistoryList: (projectPath: string) => [...workspaceQueryKeys.cliHistory(projectPath), 'list'] as const, cliExecutionDetail: (projectPath: string, executionId: string) => [...workspaceQueryKeys.cliHistory(projectPath), 'detail', executionId] as const, };