fix(worktrees): disable selector outside git repos

Expose isGitRepo on worktree listing and show Worktree: Unavailable while disabling the dropdown when a workspace folder is not a Git repository.
This commit is contained in:
Shantur Rathore
2026-02-07 15:23:27 +00:00
parent b41da03e8a
commit 3cfaf689e7
4 changed files with 47 additions and 4 deletions

View File

@@ -64,6 +64,8 @@ export interface WorktreeDescriptor {
export interface WorktreeListResponse {
worktrees: WorktreeDescriptor[]
/** True when the workspace folder resolves to a Git repository. */
isGitRepo?: boolean
}
export interface WorktreeCreateRequest {

View File

@@ -34,9 +34,9 @@ export function registerWorktreeRoutes(app: FastifyInstance, deps: RouteDeps) {
return { error: "Workspace not found" }
}
const { repoRoot } = await resolveRepoRoot(workspace.path, request.log)
const { repoRoot, isGitRepo } = await resolveRepoRoot(workspace.path, request.log)
const worktrees = await listWorktrees({ repoRoot, workspaceFolder: workspace.path, logger: request.log })
const response: WorktreeListResponse = { worktrees }
const response: WorktreeListResponse = { worktrees, isGitRepo }
return response
})