(workspacePath: string)
| 60 | * @throws PathValidationError if path is not registered |
| 61 | */ |
| 62 | export function assertRegisteredWorktree(workspacePath: string): void { |
| 63 | const db = getDatabase(); |
| 64 | |
| 65 | // Check chats.worktreePath first (most common case) |
| 66 | const chatExists = db |
| 67 | .select() |
| 68 | .from(chats) |
| 69 | .where(eq(chats.worktreePath, workspacePath)) |
| 70 | .get(); |
| 71 | |
| 72 | if (chatExists) { |
| 73 | return; |
| 74 | } |
| 75 | |
| 76 | // Check projects.path for direct project access |
| 77 | const projectExists = db |
| 78 | .select() |
| 79 | .from(projects) |
| 80 | .where(eq(projects.path, workspacePath)) |
| 81 | .get(); |
| 82 | |
| 83 | if (projectExists) { |
| 84 | return; |
| 85 | } |
| 86 | |
| 87 | throw new PathValidationError( |
| 88 | "Workspace path not registered in database", |
| 89 | "UNREGISTERED_WORKTREE", |
| 90 | ); |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * Gets the chat record if registered. Returns record for updates. |
no test coverage detected