Create new repo

merged…
osebo50d ago

I'd love to be able to create a new repo from here

2 repliesoldestnewest
Osebotfable-5-150d ago

Plan: let a workspace owner create a brand-new GitHub repo from the workspace page and have it attached to the workspace in one step.

  • API POST /api/github/repos — body { name, private?, description?, workspaceId?, alias? }. Creates the repo with the requester's GitHub OAuth token (the existing repo scope already allows this) via POST /user/repos, or POST /orgs/:org/repos when name is org/name. Always auto_init: true — the launcher does git checkout -b thread/… origin/<defaultBranch>, so an empty repo would crash every run. If workspaceId is given it checks owner membership before calling GitHub, then addRepo()s with the real default_branch from the response. Surfaces GitHub's own error message (e.g. "name already exists").
  • UI — new components/create-github-repo.tsx: a "create a new GitHub repo" link next to "browse your GitHub repos" in the Repos card (owner only) that expands into name / description / private checkbox / alias. Submits, then router.refresh().
  • Token lookup gets a small shared helper so GET and POST /api/github/repos don't each duplicate the accounts query.
  • Typecheck, static mockup screenshot, push, open PR.
Osebotfable-5-150d agothreadide@405c7ec

Done — PR #46, branch thread/67ef89c5.

How it works

On a workspace page you own, the Repos card now has "create a new GitHub repo" next to "browse your GitHub repos". It expands into name / description / private (default on) / alias. Submit → the repo is created on GitHub under your account and attached to the workspace in one go; the page refreshes with it in the list. Type org/name to create under an org instead (the osebo/ prefix in the field disappears when you do).

Behind it

  • POST /api/github/repos { name, description?, private?, workspaceId?, alias? } — uses the requester's GitHub OAuth token (the existing repo scope already allows repo creation, no re-auth needed). GET on the same route (the picker) now shares a userGithubToken() helper in lib/data.ts that also refreshes expiring GitHub App tokens like ownerGithub does.
  • Always auto_init: true — this is the important bit. lib/agent/launch.ts runs git checkout -b thread/… origin/<defaultBranch>; on an empty repo that fails and every run would die with "crashed before finishing". The README commit gives Claude a main to branch from. The stored defaultBranch comes from GitHub's response, not assumed.
  • Owner membership is checked before calling GitHub, so a 403 can't leave an orphan repo. GitHub's own error text is surfaced in the form (e.g. "GitHub: name already exists on this account", returned as 409).
  • Files: app/api/github/repos/route.ts, components/create-github-repo.tsx (new), app/workspaces/[id]/page.tsx, lib/data.ts, app/globals.css (.repo-sources, form.repo-create*), README.

Caveats

  • Not exercised against GitHub for real — doing so from the sandbox would create repos on your account. The call is a plain POST /user/repos / POST /orgs/:org/repos; worth one try after merge (a throwaway private repo, then delete it on GitHub). Org creation needs you to have create-repo permission in that org; otherwise GitHub returns 404/403 and the form shows it.
  • Not on the /workspaces create-workspace form (that's a plain URL textarea). Flow is: create workspace → open it → create repo. Easy follow-up if wanted.
  • Screenshot is a static mockup against the real stylesheet (app can't run in the sandbox). Noticed while shooting, pre-existing and untouched: long aliases like threadide/ wrap in .repo-row's 90px column, and the old "Add repo" URL row gets squeezed at 390px.

tsc --noEmit clean.

Repos card with the new "create a new GitHub repo" form expanded (static mockup against app/globals.css, 760px)
Repos card with the new "create a new GitHub repo" form expanded (static mockup against app/globals.css, 760px)