fix(staged): eliminate UI pauses during project creation - #553
Conversation
Remove two blocking GitHub API round-trips from the create_project path: 1. Remove redundant backend subpath validation — the frontend already validates via SubpathInput.waitForValidation() before submission, so the synchronous re-validation in the backend was a duplicate ~500ms-2s network call. 2. Pre-fetch the default branch in the frontend when a repo is selected (RepoConfigForm now calls detectDefaultBranch in the background). The result is passed as an optional `defaultBranch` parameter to createProject/addProjectRepo. The backend falls back to calling detect_default_branch_for_repo when the frontend doesn't provide it (e.g. error, or MCP callers without prefetch). Together these changes eliminate both pauses identified in the analysis: - Click → Spinner delay (subpath re-validation) - Spinner → Dialog close (default branch detection) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…hrough add-repo flow Fix race condition in RepoConfigForm.prefetchDefaultBranch where quickly switching repos could overwrite defaultBranch with a stale value by checking that selectedRepo hasn't changed before writing the result. Also thread the pre-fetched defaultBranch through the add-repo flow (AddRepoModal → ProjectHome.handleRepoSelected → addProjectRepo) so the add-repo path gets the same latency improvement as project creation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… nit Address code review comments: - Extract duplicated default-branch resolution logic from lib.rs and project_commands.rs into git::resolve_default_branch helper - Normalize null to undefined for defaultBranch in AddRepoModal selection Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 37c5bf76b0
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if (selectedRepo) { | ||
| checkIfMonorepo(selectedRepo); | ||
| prefetchDefaultBranch(selectedRepo); |
There was a problem hiding this comment.
Clear stale default branch before async prefetch
When selectedRepo changes, this effect starts a new async prefetch but leaves the previous repo's defaultBranch value in place until the request resolves. If the user switches repos and submits quickly, NewProjectForm/AddRepoModal can send the stale branch to the backend, and resolve_default_branch will trust it, potentially recording a non-existent base ref (for example origin/master on a repo whose default is main) and causing later worktree setup/fetch failures.
Useful? React with 👍 / 👎.
| // Subpath validation is handled by the frontend before submission | ||
| // (SubpathInput.waitForValidation). Skipping the redundant backend | ||
| // re-validation here removes a ~500ms-2s GitHub API round-trip. |
There was a problem hiding this comment.
Restore backend subpath checks for MCP add-repo path
This removal assumes subpath validation always happens in the UI, but add_project_repo_impl is also called by the MCP add_project_repo tool, where subpath is agent-provided and does not go through SubpathInput.waitForValidation. As a result, invalid/typo subpaths are now accepted and persisted, and follow-up operations (workspace clone/session working directory under that subpath) can fail only after the repo has already been added.
Useful? React with 👍 / 👎.
Summary
resolve_default_branchhelper ingithub.rsto deduplicate the default-branch resolution logic and guard the prefetch race conditionTest plan
Nonefor default branch, falls back to API)🤖 Generated with Claude Code