Skip to content

Pick the branch a new floor is cloned on - #371

Open
zcus0 wants to merge 1 commit into
AgentSystemLabs:mainfrom
zcus0:elevator-pick-branch
Open

zcus0 wants to merge 1 commit into
AgentSystemLabs:mainfrom
zcus0:elevator-pick-branch

Conversation

@zcus0

@zcus0 zcus0 commented Oct 13, 2026

Copy link
Copy Markdown

Adding a project always cloned the repository's default branch, so a new floor could only ever start on main. The elevator's Add a project now has a Branch row under the repository list.

What it does

  • Under the repository list: Branch, on Default branch unless another of the repository's is picked. The office asks GitHub for the list (gh api repos/<owner>/<name>/branches) as soon as a repository is picked, debounced while typing. A repository's default branch is always offered, even if the list was cut short before it, and each floor's row now shows the branch its checkout is on (acme/api · 🌿 feature/login).
  • The clone stays a full clone: the picked branch is git's own --branch after the --, so the floor still has every branch to work from and only its checkout starts where they picked.
  • A checkout that's already on disk (a floor taken off the building, or one cloned by hand) is moved onto the picked branch with git checkout — which makes it from origin if it isn't there yet, and refuses rather than losing work on a dirty one.
  • branch is optional end to end, so agent-office setup --project owner/repo and the other CLI paths are unchanged.
  • Branch names are checked against git's own rules (normalizeBranch) on the way in, both for what gh hands back and for what a client sends, so a hand-written message can never reach git clone --branch or git checkout with an option, a path or a revision of its own.
  • A clone that fails because the branch isn't on the repository says so in those words, rather than leaving git's own message.

Where it lives

  • src/shared/floors.ts: normalizeBranch.
  • src/shared/protocol/floors.ts: BranchChoices, branch on floor.add, and floor.branches both ways.
  • src/server/repos.ts (new): the gh listings — listRepos and listBranches — moved out of building.ts, which keeps it within the 600-line budget. Building.repos()/Building.branches() call into them.
  • src/server/clone.ts: CloneRunOptions.branch, passed to gh repo clone as --branch.
  • src/server/ws/handlers/floors.ts: the floor.branches handler.
  • src/client/ui/elevator.ts + elevator.css: the Branch row and the branch on each floor's row.
  • README.md, docs/features.md, docs/how-it-works.md: the picker, and what the clone does with it.

Verified

  • npm run typecheck, npm test (618 pass, including new cases for a clone onto a picked branch, a refused branch name, a checkout on disk put on a branch, and the branch list's filtering) and npm run build.
  • Headless-browser screenshot of the panel with the Branch row, and of the state where the list couldn't be read (the note beside it says the floor is cloned on its default branch).

🤖 Generated with [CC]

Adding a project always cloned the repository's default branch, so a
floor could only ever start on main. The elevator's "add a project"
now has a Branch row under the repository list: the default branch
unless another of the repository's is picked, which the office asks
GitHub for as soon as someone picks the repository.

The clone stays a full clone — the picked branch is git's own
`--branch` after the `--`, so the floor still has every branch to work
from and only its checkout starts where they picked. A checkout
already on disk (a floor taken off the building, or one cloned by
hand) is moved onto the picked branch with `git checkout`, which
makes it from origin if it isn't there yet and refuses rather than
losing work on a dirty one. `floor.add`'s branch is optional end to
end, so the CLI paths are unchanged, and branch names are checked
against git's own rules on the way in, so a hand-written message can
never reach `git clone --branch` or `git checkout` with something
else in it.

The GitHub listing moved to `src/server/repos.ts`, which keeps
building.ts within its size budget.

Co-Authored-By: [CC] <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants