Repository navigation
perf(desktop): create windows before the background service connects - #49763
Merged
Merged
Conversation
BackgroundServiceState awaited the first CLI service connection while the layer was built, and windows are only created after every layer has built. Fork the initial connect instead and let consumers await its first outcome through 'connection', so the renderer loads its bundle while the main process resolves the service. On its own the gain is small because the WSL layer still awaits the CLI version spawn; with the version cache (#49762) the renderer process starts 32 ms earlier (512 -> 480 ms median) and the shell is visible at 932 ms instead of 961 ms.
jinhuang712
pushed a commit
to jinhuang712/opencode
that referenced
this pull request
Sep 26, 2026
divyanshusingh2903
added a commit
to divyanshusingh2903/forge
that referenced
this pull request
Oct 21, 2026
Create the main windows before waiting on the sidecar health check; the renderer already awaits the sidecar credentials over IPC, so it can paint while the server boots. Also run the login-shell environment probe asynchronously so it overlaps Electron startup and window creation instead of blocking the main process. On a dev build the renderer now reaches the server request at ~0.8s instead of ~5.2-6.2s after launch. Window ordering adapted from upstream 5b565e8 (anomalyco#49763) and e1e2efe (anomalyco#49869); the async shell probe is Forge's own.
3 of 6 tasks
divyanshusingh2903
added a commit
to divyanshusingh2903/forge
that referenced
this pull request
Oct 21, 2026
Create the main windows before waiting on the sidecar health check; the renderer already awaits the sidecar credentials over IPC, so it can paint while the server boots. Also run the login-shell environment probe asynchronously so it overlaps Electron startup and window creation instead of blocking the main process. On a dev build the renderer now reaches the server request at ~0.8s instead of ~5.2-6.2s after launch. Window ordering adapted from upstream 5b565e8 (anomalyco#49763) and e1e2efe (anomalyco#49869); the async shell probe is Forge's own. Upstream: anomalyco/opencode@5b565e8923 (anomalyco#49763) Upstream: anomalyco/opencode@e1e2efe8ec (anomalyco#49869)
divyanshusingh2903
added a commit
to divyanshusingh2903/forge
that referenced
this pull request
Oct 21, 2026
Create the main windows before waiting on the sidecar health check; the renderer already awaits the sidecar credentials over IPC, so it can paint while the server boots. Also run the login-shell environment probe asynchronously so it overlaps Electron startup and window creation instead of blocking the main process. On a dev build the renderer now reaches the server request at ~0.8s instead of ~5.2-6.2s after launch. Window ordering adapted from upstream 5b565e8 (anomalyco#49763) and e1e2efe (anomalyco#49869); the async shell probe is Forge's own. Upstream: anomalyco/opencode@5b565e8923 (anomalyco#49763) Upstream: anomalyco/opencode@e1e2efe8ec (anomalyco#49869)
divyanshusingh2903
added a commit
to divyanshusingh2903/forge
that referenced
this pull request
Oct 21, 2026
Create the main windows before waiting on the sidecar health check; the renderer already awaits the sidecar credentials over IPC, so it can paint while the server boots. Also run the login-shell environment probe asynchronously so it overlaps Electron startup and window creation instead of blocking the main process. On a dev build the renderer now reaches the server request at ~0.8s instead of ~5.2-6.2s after launch. Window ordering adapted from upstream 5b565e8 (anomalyco#49763) and e1e2efe (anomalyco#49869); the async shell probe is Forge's own. Upstream: anomalyco/opencode@5b565e8923 (anomalyco#49763) Upstream: anomalyco/opencode@e1e2efe8ec (anomalyco#49869)
divyanshusingh2903
added a commit
to divyanshusingh2903/forge
that referenced
this pull request
Oct 21, 2026
Create the main windows before waiting on the sidecar health check; the renderer already awaits the sidecar credentials over IPC, so it can paint while the server boots. Also run the login-shell environment probe asynchronously so it overlaps Electron startup and window creation instead of blocking the main process. On a dev build the renderer now reaches the server request at ~0.8s instead of ~5.2-6.2s after launch. Window ordering adapted from upstream 5b565e8 (anomalyco#49763) and e1e2efe (anomalyco#49869); the async shell probe is Forge's own. Upstream: anomalyco/opencode@5b565e8923 (anomalyco#49763) Upstream: anomalyco/opencode@e1e2efe8ec (anomalyco#49869) Co-authored-by: Luke Parker <[email protected]>
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.
BackgroundServiceState.makeawaited the first connection to the CLI service while its layer was being built, anddesktop.tsonly creates windows after every layer has built. So the renderer could not start loading its bundle until the main process had finished talking to the service.connectionawaits its first outcome through aDeferred, so no consumer observes the service before it exists and the failure path (die on connect error) is unchangedreconnectbehaviour is unchangedOn its own the gain is small: the WSL layer still waits for the bundled CLI's
--versionspawn, which dominates the same critical path. Together with #49762 (version cache) the window no longer waits on any CLI round-trip.Measured with
bun run bench:startup(#49758): packagedv2build, isolated home, warm service, 5 launches, median ms since process spawn.