From 10a5c29702e7db4750cf4f87aaad77fa7ad98085 Mon Sep 17 00:00:00 2001 From: Alex Blank Date: Sun, 24 May 2026 09:18:29 +0000 Subject: [PATCH] docs: add session branch selection design spec - Design for branch dropdown in session creation - New local branch creation at clone time - Frontend/backend changes overview --- ...6-05-24-session-branch-selection-design.md | 155 ++++++++++++++++++ 1 file changed, 155 insertions(+) create mode 100644 docs/superpowers/specs/2026-05-24-session-branch-selection-design.md diff --git a/docs/superpowers/specs/2026-05-24-session-branch-selection-design.md b/docs/superpowers/specs/2026-05-24-session-branch-selection-design.md new file mode 100644 index 0000000..2214a5f --- /dev/null +++ b/docs/superpowers/specs/2026-05-24-session-branch-selection-design.md @@ -0,0 +1,155 @@ +# Session Branch Selection with New Branch Creation + +## Summary + +Replace the free-text branch input in the session creation form with a dropdown of available branches from the repository. Add the ability to create a new local branch at clone time by selecting "Create new branch..." from the dropdown. + +## Context + +The current session creation UI (`apps/web/src/pages/sessions.tsx`) has a free-text input for the branch name when "Clone fresh copy" mode is selected. Users must manually type the branch name, which is error-prone and doesn't show what branches are available. + +The backend already has: +- A `GET /projects/{project_id}/repositories/{repo_id}/branches` endpoint that returns all branches and the default branch +- A `clone_repository` service that clones a specific branch +- Branch creation APIs for the original repository + +## Design + +### Frontend Changes + +#### 1. Branch API Integration + +Add a new API function in `apps/web/src/api/git_repositories.ts`: + +```typescript +export interface Branch { + name: string; + is_default: boolean; + last_commit: string | null; +} + +export interface BranchesResponse { + branches: Branch[]; + default_branch: string; +} + +export async function listRepositoryBranches( + projectId: string, + repoId: string +): Promise { + const response = await apiClient.get( + `/projects/${projectId}/repositories/${repoId}/branches` + ); + return response.data; +} +``` + +#### 2. UI State Management + +In `apps/web/src/pages/sessions.tsx`, add state for: +- `branches`: `Branch[]` — loaded when a repository is selected and clone mode is active +- `isLoadingBranches`: `boolean` +- `isCreatingNewBranch`: `boolean` — toggled when "Create new branch..." is selected +- `newBranchName`: `string` — the name for the new branch +- `baseBranch`: `string` — the base branch for the new branch + +#### 3. Branch Loading + +When a repository is selected and clone mode is "clone", fetch branches: +- Call `listRepositoryBranches(selectedProject, selectedRepo)` +- Set `baseBranch` to `default_branch` from the response +- If the current `branch` state is not in the list, reset it to `default_branch` + +#### 4. Branch Dropdown + +Replace the free-text input with a `