Skip to content

Sync local git remains in resolveThreadGit / defaultBranch on the PR read paths #228

Closed

Description

@currentbits

Split out of #124, which converted the dominant offenders. This is the small honest remainder.

electron/worktrees.js no longer runs any synchronous gh (sync ghTry was deleted). But two helpers still use the synchronous execCommand git wrapper, and they sit on paths that are read-only and user-facing:

  • resolveThreadGit (~line 1520) — used by prStatus, createPr, mergePr
  • defaultBranch (~line 187) — used by listPrs, createPr, and the worktree flows

So listPrs and prStatus now have async gh but still make ~2 synchronous local git calls each (remote get-url origin, branch --show-current).

Why this was left

Scale. Measured in #124, local git under concurrency is ~30-50ms p99; the gh calls that were fixed were bounded at 30_000ms and are network-bound. Two local git calls on a PR view is real but roughly three orders of magnitude below what was actually causing the beachball, and converting resolveThreadGit cascades into the worktree write flows (setupWorktree, mergeWorktree, push, commit, revertFile, cleanupWorktree) which are all still deliberately sync.

Deliberately still sync, and fine

The worktree write paths — setupWorktree, mergeInto / mergeWorktree, push, commit, revertFile, cleanupWorktree, unmergedFiles, maybeRenameWorktreeBranch. They fire once per deliberate click and are bounded at 15s by #88. Marked in-file with a ponytail: comment at the sync gitOut helper so the remainder is documented rather than rediscovered.

Worth doing when

If event-loop lag instrumentation (CODER_LOOP_LAG=1, added in #124) shows the PR/Git tab still contributing measurable p99 under concurrent runs. Measure before converting — that is what #124 established as the working method, and it is what stopped the store-stringify work from being a guess.

Async helpers already exist in the file (gitOutAsync, gitOutForDiffAsync, gitTryAsync, gitExecThrowAsync), so this is routing, not new machinery.

Activity

  1. added and removed on Aug 17, 2026
  2. currentbits commented on Aug 17, 2026

    @currentbits
    OwnerAuthor

    Scoping note before implementation: the premise in the issue body is stale against origin/main (7140d2e).

    • electron/worktrees.js:1122 still defines the synchronous ghTry (execFileSync, 30_000ms bound), and listPrs, prStatus, prChecks, createPr, mergePr are all still synchronous functions that use it. Sync gh was not deleted.
    • CODER_LOOP_LAG does not exist anywhere in the tree, so the "measure first" instrumentation App beachballs when multiple threads run concurrently #124 was supposed to leave behind is not available either.

    So the PR read paths block the main process on network-bound gh (30s ceiling), not just on ~2 local git calls (~30-50ms). Fixing only the local git half while a 30s sync gh sits on the same line would be theatre.

    Scope taken:

    • resolveThreadGit -> async (every caller is a PR path).
    • new defaultBranchAsync; sync defaultBranch stays for the worktree write flows.
    • read paths listPrs / prStatus / prChecks -> async, ghTry -> ghTryAsync at the interactive 30s timeout.
    • createPr / mergePr become async (they await resolveThreadGit) but keep sync ghTry and sync push/commit internals - deliberate-click write paths, unchanged per the issue.

    Not doing: CODER_LOOP_LAG instrumentation (not asked for here), and no conversion of the worktree write flows.

  3. added a commit that references this issue on Aug 17, 2026
  4. added and removed on Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions