🤖 perf: defer workspace-open git/PR probes until the chat replay settles - #4675
Merged
Merged
Conversation
…eplay settles Opening a workspace mounted footer/link components whose git status, git fetch, gh pr view and gh stack view probes spawned ~5 ms before the onChat history replay, blocking the Electron main process and rendering results during the transcript paint (#4662). WorkspaceStore now reports whether the active workspace's first replay is still pending (cleared on caught-up, on an attempt that ends without caught-up, and on deactivation/removal). GitStatusStore and PRStatusStore skip pending workspaces in their refresh loops and arm a one-shot watcher that requests an immediate refresh when the gate opens. Cached status stays visible during the deferral. Signed-off-by: Thomas Kosiewski <tk@coder.com>
… stores Move the per-workspace retry-map bookkeeping into deferWhileChatReplayPending so GitStatusStore and PRStatusStore no longer duplicate it, and pass the workspaceStore arrow methods to the gate directly. Behavior-neutral.
…th probes bun does not interpolate booleans into %s, so both it.each cases shared one title. Use string cases and check that the deferred refresh issues gh pr view as well as gh stack view.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Opening a workspace no longer starts its git status, git fetch,
gh pr viewandgh stack viewprobes while the chat history replay is still running. The probes now start when the chat reachescaught-up. On cold opens, the first transcript row appears ~70-95 ms sooner, and the server replay is 2-3x faster.Refs #4662
Background
Opening a workspace mounts the footer, branch selector and PR links. Their store subscriptions queued an immediate refresh, which sent four
workspace.executeBashcalls ~5 ms before the onChat replay began. Each child-process spawn blocks the Electron main process for ~8-16 ms, so the replay's history read ran on a stalled event loop (found while diagnosing #4624; #4670 fixed the untrusted-project part of that measurement).Implementation
WorkspaceStore.isWorkspaceChatReplayPending(id)is true from the moment a workspace becomes the active onChat subscription until one of these happens:Each of these paths notifies
subscribeKeylisteners. No timers are involved.GitStatusStoreandPRStatusStoreaccept that gate viasetChatReplayGate, wired once inAppLoader.deferWhileChatReplayPending) callsrequestImmediate()when the gate opens.Validation
perf.chatSwitch(--workers 1), 4 alternating base/after runs on the same host, 12 switches per column per build. Medians, in ms:The renderer's longest task did not change. In these baseline runs the probe results did not land during the paint (base longest task 69/104 ms, not the 146 ms seen in #4624), so this PR does not claim a longest-task improvement. The numbers were measured at the first commit; the later commits are a behavior-preserving refactor and a test-only rename.
Remote dogfood UAT (Coder Agents, browser mode, real git repo with a GitHub PR) passed:
Risks
Low. This only changes when the passive git/PR refreshes of the active workspace run. They are late by at most the replay duration, or by one failed attempt (bounded by the stall watchdog) if caught-up never arrives. With no gate wired (tests, stories), behavior is unchanged. The untrusted-project no-repo git env check (#4661) is untouched.
Generated with
xum• Model:anthropic:claude-opus-5-5• Thinking:high