GeezerVison is showing github.com — fix(desktop): typing no longer freezes while the renderer polls topology by juliusmarminge · Pull Request #23601 · pingdotgg/t3code
Conversation
Problem
The desktop renderer read local-environment topology with ipcRenderer.sendSync on every 3 s platform poll (getLocalEnvironmentBootstraps, getLocalEnvironmentEnabled), and getLocalEnvironmentEnabled also ran on composer renders. Each call parks the renderer thread until the main process answers, so any main-process stall freezes typing, even in an empty chat. The browser UI on the same backend has no desktopBridge and stays smooth. Reproduced on the real Linux desktop build at origin/main: typing into a new empty chat while the main process runs a 1 s blocking task every 3 s, the renderer froze inside sendSync for up to 885 ms (long tasks 885/554/476/464/350 ms), the same signature as the reporters' Windows profiles.
Change
- Main registers the existing bootstrap snapshot handler a second time as an async
invoke handler on the same channel. The sync handler stays for the one startup read.
- The preload caches the bootstrap snapshot from that startup read and exposes
refreshLocalEnvironmentBootstraps, which refreshes the cache over invoke. getLocalEnvironmentBootstraps now returns the cache.
getLocalEnvironmentEnabled is read once per page. Changing it already relaunches the app.
- The platform poll awaits the async refresh before it reads the primary target and the secondaries, so a topology change still lands within one poll. When the bridge has no refresh method, the web reader falls back to the sync read.
This re-lands the approach of https://git.cafe/pingdotgg/t3code/pulls/19300, which https://git.cafe/pingdotgg/t3code/pulls/22222 reverted only because it had not been run on a real desktop build. The refresh now runs before the primary read.
Scope and approval
Fixes #12689
GitCafe: https://git.cafe/pingdotgg/t3code/issues/12689
Triaged bug via the automated issue flow (labelled accepted, bug). The maintainer triage comment on the issue names this fix: stop polling the topology snapshot over sendSync.
Verification
Focused tests:
apps/desktop: vp test run src/preload.test.ts src/ipc passed 20/20. polling topology reads do not block the renderer on synchronous IPC each time failed on main with expected 5 to be less than or equal to 1 for both channels, and passes now.
apps/web: vp test run src/connection passed 30/30, including the new async refresh case (secondary appears, failed refresh keeps the snapshot, empty refresh clears it).
Real desktop build, Linux (Electron 44.9.3 on Xvfb, --no-sandbox --disable-gpu), with existing user state seeded by vp run migrate-dev-db. A CDP probe typed 300 keys at 40 ms into a new empty chat while CPU-profiling the renderer. "busy" means the main process ran a 1 s blocking task every 3 s.
| run |
sendSync sampled |
longest sendSync |
renderer long tasks > 200 ms |
| main, idle |
69 ms |
13.9 ms |
228, 216 |
| main, busy |
888 ms |
428 ms |
885, 554, 476, 464, 350 |
| fix, idle |
0 |
0 |
none (max 176) |
| fix, busy |
0 |
0 |
none (max 81) |
desktop.trace.ndjson: main made 693 sync topology calls in an 810 s session. The fix makes 2 sync calls at startup, then an async invoke on the same channel every ~3 s. The sync and async handlers on one channel coexist in the real build.
- Keystroke dispatch p99 under the busy main stays ~1.06 s both before and after, because Electron routes input through the main thread itself. The fix removes the renderer-side freeze, not main-process stalls.
- Full transcript: probe-transcript.md
The fixed build with existing user state connects to the local environment and loads the seeded threads. There is no visual change to compare, so these are after-only:
| New chat with seeded threads (fix) |
Settings › Connections (fix) |
 |
 |
Unverified here:
- Windows, where the issue was reported.
- macOS desktop.
- A WSL secondary backend appearing or disappearing mid-session.
Those paths run the same preload and web code. They are covered only by the unit tests above.
Claude Opus 5.5 (claude-opus-5-5) via Claude Code in T3 Code; reviews by Claude Opus 5.5 and Claude Sonnet 5.5.
🤖 Generated with Claude Code
Independent review and proof audit (head fc736575)
Reviews (read-only, full diff against main, with #19300 and #22222):
- Claude Sonnet 5.5:
VERDICT: MERGE. Found no concrete defect; the new tests pass. A topology change reaches both the primary and the secondaries within one poll, now that the refresh runs before the primary read. The sync and async handlers on one channel don't conflict. The fallback for older desktop shells is the old sync read.
- Claude Opus 5.5:
VERDICT: NEEDS_JULIUS. Found no blocking defect. Its reason is the re-land bar from https://git.cafe/pingdotgg/t3code/pulls/19300 (a real build with user state on every platform it touches): only Linux has been run. Between polls, readers outside the poll see data up to one poll old. The bootstrap token can't go stale in that time because the backend accepts a 3-window, 12 h range. A newer desktop paired with an older web build would never refresh, but the desktop always loads its own bundled web.
Proof audit: pass 1 INSUFFICIENT 1,2,3,5. The runs weren't pinned to a SHA, the topology change had never been run on a real build, and the driver wasn't published. After new captures, pass 2 VERDICT: SUFFICIENT.
New rows. Real Linux desktop build (Electron 44.9.3, Xvfb, --no-sandbox --disable-gpu) with state seeded by vp run migrate-dev-db into an isolated home. before = 8d3b061121 (2 commits behind main, with no topology changes between them); after = fc736575.
| Row |
before 8d3b061121 |
after fc736575 |
| Startup, topology IPC in the first 10 s |
10 sync |
1 sync, then async invoke every ~3 s |
| Existing user state |
threads load, connected (screenshot) |
threads load, connected (screenshot) |
| Secondary added, removed, added, removed in main; when the renderer sees it |
2269 / 2496 / 677 / 2485 ms |
2535 / 2501 / 692 / 2489 ms (within one poll). A primary label change took ≤ 2490 ms. |
| Async refresh rejects for 5 polls (13 s) |
N/A (no refresh method) |
Snapshot kept the primary and the secondary throughout, with no offline banner. The first good poll applied a change 2472 ms after the handler was restored. |
Idle typing: sendSync ms / longest / long tasks > 200 ms / key p99 |
11.2 / 2.9 / none / 32 ms |
0 / 0 / none / 39 ms |
| Busy typing, random phase (5 before runs, 3 after) |
1 of 5 runs froze: 332.6 / 314 / [317] / 993 ms |
0 / 0. One run had a 569 ms long task with no sendSync (GC and editor work). |
| Busy typing, 1 s block aligned to the poll (2 runs each) |
1718.7 / 1009.9 / [1005, 702]; 1708.1 / 999.9 / [1000, 702] |
0 / 0 / none (max 67) |
The busy rerun confirms the body's table in mechanism: the same two preload sendSync frames, on before only. The size depends on the phase. A random-phase run hits a poll only sometimes; when the block is aligned to the poll, the before build froze for about 1 s in every run.
Driver ev-23601-driver.tgz, sha256 ce5a568d5250d512745f23e1585cc48147d307268bc0bc270e10b094e3e1253a (driver.mjs alone: f4b30c952194eb2c0b85f82f71db725ac5ae8fe75410b07294861bedd14a9eea). Results: captures.md, raw JSON and CPU profiles: ev-23601-data.tgz.
Verification log
- 2026-10-22, fs-17, head
fc736575710b11a7aa4c729aabee38d5eae3c907. Evidence only: no code changes and no pushes.
- Reviews: Claude Sonnet 5.5 MERGE, Claude Opus 5.5 NEEDS_JULIUS.
- Proof audit: pass 1 INSUFFICIENT 1,2,3,5; pass 2 SUFFICIENT.
- Captures used the real Linux desktop build (
vp run build:desktop succeeded; no libsecret workaround needed).
- How the rows were injected: the secondary was injected into the main backend pool's live instance map through the main inspector, and the failed refresh replaced the async
invoke handler with one that throws.
- Caveats:
- The first R1 attempt cloned the primary's URL and auth, which caused an offline banner. That run was discarded; the reported runs are from clean sessions.
- The before data file for busy random-phase run 1 was transcribed from console output after its profile was overwritten.
- The published driver is a later revision than the one that ran the before idle and busy runs.
- Audit pass 2 noted that two sentences in the body above don't match the transcript. The "885 ms inside
sendSync" was the longest long task; the longest sendSync was 428 ms. The keystroke p99 under busy main was 1167 ms before and 1064 ms after, not ~1.06 s both ways. Left for the author to correct.
- Unverified: Windows (where https://git.cafe/pingdotgg/t3code/issues/12689 was reported), macOS desktop, and a real WSL secondary appearing or disappearing mid-session.
- Model and harness: Claude Opus 5.5 (claude-opus-5-5) via Claude Code in T3 Code (lead, capture, audits); reviewers Claude Sonnet 5.5 and Claude Opus 5.5.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
josephv123 reacted with thumbs up emoji
These tests reproduce #12689: every topology poll calls the
sendSync-backed bridge reads for bootstraps and local-environment
enabled, so a busy main process freezes the renderer while typing.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Every 3 s topology poll and every composer render called sendSync for the
local-environment bootstraps and enabled flag, so a busy main process froze
the renderer while typing (#12689).
The preload now reads each value synchronously once for the first paint and
caches it. The enabled flag only changes through a setter that relaunches the
app, so the startup value stays correct. Bootstraps are refreshed by a new
async bridge method over ipcRenderer.invoke on the same channel; the platform
poll awaits it before reading the primary and secondary topology, so a
WSL/secondary backend appearing, disappearing or changing still reaches the
UI within one poll.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Approvability
Verdict: Approved at 692eb7a
Macroscope's review found this PR approvable — Topology polling now refreshes desktop bootstrap data asynchronously instead of repeatedly blocking the renderer. The change preserves existing snapshot contents and connection handling, with no material change to defaults, permissions, or persistent data.
You can add or adjust custom eligibility rules. Learn more.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Thread transfer impact
✅ Thread transfer remains within every enforced ceiling.
| Provider |
Metric |
Main baseline |
This PR |
Impact |
PR ceiling |
|
| Codex |
Total thread wire |
5.0 KiB |
5.0 KiB |
0 B (0.0%) |
6.8 KiB |
✅ |
| Codex |
Thread snapshot wire |
3.8 KiB |
3.8 KiB |
0 B (0.0%) |
4.9 KiB |
✅ |
| Codex |
Live turn WebSocket wire |
1.2 KiB |
1.2 KiB |
0 B (0.0%) |
2.0 KiB |
✅ |
| Codex |
Live turn WebSocket decoded |
21.5 KiB |
21.5 KiB |
0 B (0.0%) |
24.4 KiB |
✅ |
| Codex |
Live turn messages |
1 |
1 |
0 (0.0%) |
8 |
✅ |
| Claude |
Total thread wire |
5.0 KiB |
5.0 KiB |
0 B (0.0%) |
6.8 KiB |
✅ |
| Claude |
Thread snapshot wire |
3.8 KiB |
3.8 KiB |
0 B (0.0%) |
4.9 KiB |
✅ |
| Claude |
Live turn WebSocket wire |
1.2 KiB |
1.2 KiB |
0 B (0.0%) |
2.0 KiB |
✅ |
| Claude |
Live turn WebSocket decoded |
21.9 KiB |
21.9 KiB |
0 B (0.0%) |
24.4 KiB |
✅ |
| Claude |
Live turn messages |
1 |
1 |
0 (0.0%) |
8 |
✅ |
Baseline: 3a8c250 · PR result: 692eb7a · Source CI: success
Scenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
- Codex decoded thread snapshot: 108.5 KiB
- Claude decoded thread snapshot: 108.8 KiB
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Oct 22, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

No actionable comments were generated in the recent review.
Walkthrough
-
The desktop bridge now caches synchronous bootstrap reads and supports asynchronous refresh. Web topology registration awaits that refresh before reading topology.
Changes: Desktop Bootstrap Refresh
| Layer / File(s) |
Summary |
Asynchronous IPC and preload caching packages/contracts/src/ipc.ts, apps/desktop/src/ipc/methods/window.ts, apps/desktop/src/ipc/DesktopIpcHandlers.ts, apps/desktop/src/preload.ts, apps/desktop/src/preload.test.ts |
The desktop bridge adds an asynchronous bootstrap refresh method. The IPC handler shares bootstrap snapshot logic with the synchronous handler. The preload caches synchronous bootstrap and enabled-state reads, and replaces cached bootstrap data after refresh. |
Secondary topology refresh during registration apps/web/src/connection/desktopLocal.ts, apps/web/src/connection/desktopLocal.test.ts, apps/web/src/connection/platform.ts |
The secondary bootstrap reader adds asynchronous refresh and preserves its snapshot when refresh fails. Registration awaits refresh before reading topology. |
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix · Severity of issue fixed: Medium
Sequence Diagram(s)
sequenceDiagram
participant RegistrationBuilder
participant DesktopSecondaryBootstrapsReader
participant DesktopPreload
participant DesktopIpcHandlers
RegistrationBuilder->>DesktopSecondaryBootstrapsReader: await refresh
DesktopSecondaryBootstrapsReader->>DesktopPreload: refreshLocalEnvironmentBootstraps
DesktopPreload->>DesktopIpcHandlers: asynchronous bootstrap IPC
DesktopIpcHandlers-->>DesktopPreload: bootstrap snapshot
DesktopPreload-->>DesktopSecondaryBootstrapsReader: refreshed bootstrap list
DesktopSecondaryBootstrapsReader-->>RegistrationBuilder: secondary bootstrap snapshot
RegistrationBuilder->>RegistrationBuilder: read primary topology
Loading
Possibly related PRs
Suggested reviewers: maria-rcks, t3dotgg
Merge Risk: Minimal · up to 692eb
-
Topology polling no longer requires repeated synchronous bootstrap reads, and transient refresh failures preserve usable secondary connections. No actionable issue remains before merge.
Pre-merge checks: 4
-
| Check name |
Status |
Explanation |
| Title check |
 |
The title is concise, specific, and accurately describes the primary fix: preventing renderer typing freezes during desktop topology polling. |
| Description check |
 |
The description includes complete Problem, Change, Scope and approval, and Verification sections. It provides reproduction details, implementation context, linked issue approval, focused test results,… |
| Linked Issues check |
 |
Issue #12689 requires responsive desktop typing in an empty chat. The preload now caches the startup topology and refreshes it through async IPC. The platform poll awaits that refresh before reading c… |
| Out of Scope Changes check |
 |
The changes stay within issue #12689. Main-process IPC registration, preload caching, bridge typing, topology refresh logic, polling order, and focused tests directly support removal of repeated synch… |
Full details: Description check
-
Explanation
The description includes complete Problem, Change, Scope and approval, and Verification sections. It provides reproduction details, implementation context, linked issue approval, focused test results, manual desktop evidence, screenshots, limitations, and tool disclosure.
Full details: Linked Issues check
-
Explanation
Issue #12689 requires responsive desktop typing in an empty chat. The preload now caches the startup topology and refreshes it through async IPC. The platform poll awaits that refresh before reading connection targets. The enabled state is read once per page. Focused desktop and web tests cover the IPC call count, async refresh, failed refresh retention, and empty refresh. Reported Linux desktop evidence shows no repeated renderer-side sendSync calls or long tasks during busy typing. Windows remains unverified, but the issue does not require platform-specific test evidence.
Full details: Out of Scope Changes check
-
Explanation
The changes stay within issue #12689. Main-process IPC registration, preload caching, bridge typing, topology refresh logic, polling order, and focused tests directly support removal of repeated synchronous topology polling. No unrelated product behavior is shown in the reviewed change summary.
Finishing Touches
-
Generate docstrings
-
- Commit to this branch
- Create a new PR
Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Usage-based review receipt
Note This review was completed with usage-based billing: files reviewed beyond your plan's included limits are billed at $0.25/file. View usage-based billing.
Recent review info
-
Run configuration
-
Commits
-
Reviewing files that changed from the base of the PR and between fc73657 and 692eb7a.
Files selected for processing: 7
-
apps/desktop/src/ipc/DesktopIpcHandlers.ts
apps/desktop/src/ipc/methods/window.ts
apps/desktop/src/preload.test.ts
apps/desktop/src/preload.ts
apps/web/src/connection/desktopLocal.ts
apps/web/src/connection/platform.ts
packages/contracts/src/ipc.ts
Limit details: You’ve used all 10 included reviews currently available.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Numbers from two Macs on the shipped 0.1.7-nightly.20261102.4093 (macOS 27.2, Apple silicon), so before this change. I haven't run this branch.
getLocalEnvironmentBootstraps ran 2,396 to 2,398 times an hour on both Macs, flat from evening through 8 am with no one using the window.
localEnvironment.getEnabled ran about 1,200 times an hour, once every 3 s.
- With the
invokeSync, ipc.method and resolvePrimaryLabel wrapper spans, these calls are 98% of desktop.trace spans on one Mac (270,781 of 275,424) and 97% of desktop.trace bytes on the other. Each 10 MB file lasts about 2 hours.
The counts match the 3 s platform poll alone, at two bootstrap reads and one enabled read per tick. The 2 s useDesktopLocalBootstraps poll doesn't show up in them, and with this PR it reads the preload cache anyway.
After this PR, the platform poll still sends one async invoke every 3 s. That is about 1,200 an hour, and each one still runs the traced handler and resolvePrimaryLabel. On an idle Mac those would still be most of desktop.trace. Skipping the refresh while the window is hidden, or not tracing a successful refresh, would remove the rest.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
# Conflicts:
# apps/desktop/src/ipc/methods/window.ts
# apps/desktop/src/preload.ts
# packages/contracts/src/ipc.ts
…r main's preload changes
AI-assisted; verified with the tests and tools listed above.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Evidence
Built and ran both commits as real Linux Electron 44.10.1 apps on Xvfb, 1280×900, light theme, with fresh synthetic state. In a new empty chat, typed for 36 seconds at a 40 ms pace while the main process ran a controlled one-second blocking task aligned with recurring topology polling. Recorded the window and renderer CPU profile on each side.
| Before |
After |
| 3a8c250 |
692eb7a |
| Typing recording |
Typing recording |
| Renderer heartbeat visibly freezes; largest frame gap 1,000 ms. Long tasks: 850 and 1,001 ms. |
Heartbeat continues through main-process blocks; largest frame gap 217 ms. No long tasks recorded. |
| 1,883.6 ms of inclusive CPU samples inside sendSync; 22 synchronous bootstrap requests during capture. |
Zero sendSync samples; 11 asynchronous bootstrap requests during capture. |
| Renderer CPU profile |
Renderer CPU profile |
| Topology recording |
Topology recording |
| Add/remove/add/remove reconciled in 1,751 / 1,217 / 1,540 / 1,388 ms. |
Add/remove/add/remove reconciled in 2,019 / 1,366 / 1,533 / 1,387 ms, all within one three-second poll. |
Side-by-side typing recording. Around 8.7–9.7 seconds, the base heartbeat stops at 9.39 seconds while the head continues updating. Main-process input delivery delays can remain on both sides; this proves removal of the renderer-side synchronous IPC stalls.
Topology diagnostic: injected and removed a second real isolated backend's bootstrap snapshot through main-process IPC responses, then observed Connections. This was not a real WSL lifecycle test.
Drivers: typing and profiling, topology. Data: summary, before metrics, after metrics, before topology timings, after topology timings, sanitized logs.
AI-assisted; verified with the tests and tools listed above.
Not shown:
- Windows and macOS were not available for this capture; proof uses the controlled Linux desktop reproduction.
- A real WSL backend appearing or disappearing was not exercised; reconciliation used an injected snapshot from a second real isolated backend.
- The browser interface against the same backend was not captured; the comparison used desktop renderer profiles.
- Startup synchronous-read counts and async-refresh rejection retention were not separately captured.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This branch has not been deployed
No deployments
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
bugfix
Fix PR opened by an issue lead; enters the PR loop
pr:needs-julius
Needs Julius: route gate, unverifiable surface, or blocked
size:L
100-499 changed lines (additions + deletions).
vouch:trusted
Author is trusted by repo permissions or the VOUCHED list.
Milestone
No milestone
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.
|