fix(trpc,mobile): resolve the default branch server-side, paginate branch listing

Merged
SA
3mo ago
+25-8

Summary

  • Follow-ups to #6651 from CodeRabbit's review (which landed after merge):
    1. cloudWorkspace.create's branch is now optional; when omitted the server resolves the repo's actual default via repoForProject instead of a client guessing "main". The mobile create hook now omits the branch when its query hadn't resolved.
    2. listRemoteBranches paginates (up to 10 × 100, early exit on a short page) — a single request made everything past the first hundred branches unfindable, and this repo alone exceeds that.

Testing

  • bunx tsc --noEmit (trpc, mobile)
  • bun run lint
  • Behavior change is server-side fallback + pagination; exercised the same code paths against the local API in #6651's verification.

Summary by cubic

Resolve the default branch server-side and paginate branch listing to avoid missing branches. Previously, mobile guessed "main" for cloudWorkspace.create when branch was unresolved and the server listed only the first 100 branches; now the client omits branch, the server selects the repository default (falling back to "main" if unknown), and listRemoteBranches paginates up to 10×100 results.

Review notes

  • TRPC: cloudWorkspace.create.branch is optional; the server resolves via repoForProject.defaultBranch or uses "main" if unavailable. If a branch is provided, behavior is unchanged.
  • Mobile: useCreateCloudWorkspace omits branch when the branch query has not resolved.
  • Pagination: packages/trpc listRemoteBranches fetches up to 10 pages (100 per page) and exits early on a short page; no caller changes required.
  • Clients should stop guessing default branches; omit branch when unknown.

Summary by CodeRabbit

  • New Features

    • Cloud workspaces now automatically use the repository’s default branch when no branch is specified.
    • Branch selection supports repositories with more than 100 branches by retrieving results across multiple pages.
  • Bug Fixes

    • Prevented unresolved branch names from incorrectly defaulting to main before the repository’s actual default branch is determined.