Skip to content

fix(staged): eliminate UI pauses during project creation - #553

Merged
matt2e merged 3 commits into
mainfrom
staged-pause-on-project-creation
Mar 31, 2026
Merged

fix(staged): eliminate UI pauses during project creation#553
matt2e merged 3 commits into
mainfrom
staged-pause-on-project-creation

Conversation

@matt2e

@matt2e matt2e commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Prefetch the default branch in the frontend (RepoConfigForm) while the user is filling out the form, then thread it through to the backend to avoid a ~500ms-2s GitHub API round-trip during project/repo creation
  • Remove redundant backend subpath validation that duplicates frontend validation (SubpathInput), eliminating another blocking API call
  • Extract a resolve_default_branch helper in github.rs to deduplicate the default-branch resolution logic and guard the prefetch race condition

Test plan

  • Create a new remote project — should complete without noticeable pause
  • Add a repo to an existing project — should complete without noticeable pause
  • Verify subpath validation still works in the frontend before submission
  • Verify MCP project creation still works (passes None for default branch, falls back to API)

🤖 Generated with Claude Code

matt2e and others added 3 commits March 31, 2026 10:40
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>
@matt2e
matt2e requested review from baxen and wesbillman as code owners March 31, 2026 02:32

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines 118 to +120
if (selectedRepo) {
checkIfMonorepo(selectedRepo);
prefetchDefaultBranch(selectedRepo);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment on lines +48 to +50
// 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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@matt2e
matt2e merged commit 335295a into main Mar 31, 2026
4 checks passed
@matt2e
matt2e deleted the staged-pause-on-project-creation branch March 31, 2026 03:01
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.

1 participant