# 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 `