Agent-created preview tabs in background threads had no desktop host until their chat mounted. The desktop host now discovers threads from the primary environment's preview events and mounts the existing per-thread session sync. Chat and desktop share that sync, including list reconciliation and tab closure. The shared preview event subscription also delivers each event separately to the atom, so a batch cannot hide an earlier thread open or tab close.
This finishes @MahirAbbas's original contribution, preserves the contributor's commits, and merges main at ab6be13d43 to resolve the conflict.
Verification at 68c1401c:
- Replaced the obsolete standalone hook test with one behavior case in the existing browser suite: discovery, list reconciliation, and close without mounting chat. Removing desktop discovery makes it fail.
- 92 focused tests pass across seven files: 40 client-runtime tests, six browser tests, and 46 web unit tests. One added runtime regression verifies all opens and closes from RPC batches; it fails before the delivery fix (39 pass / one fail) and passes after. Client-runtime and web typechecks, targeted lint, formatting, and diff checks pass.
- Two full-diff review rounds with Codex and Claude. Round one found batched event loss; the shared subscription fix and focused failing-before regression address it. Both reviewers found no remaining code blockers in round two and independently passed the 40 runtime tests.
- Native Electron 44.4.5 on headless Linux/Xvfb ran the production desktop host, hosted webview, session sync, and CDP relay with synthetic environment/IPC boundaries. With discovery disabled, the same event creates zero webviews. At this head it creates one webview and attaches it with chat absent; a duplicate event keeps one, CDP returns the guest title, and close removes the webview and detaches it. Before output; after output.
Before — discovery disabled in the production host, with otherwise matching fixture/data/viewport:

After — reviewed head:

Limits: this native integration fixture is not the packaged T3 desktop app. It substitutes transport, settings/permissions, and unexercised UI boundaries; it does not prove the full server fallback transition or CPU reduction. Previously existing tabs still need a subsequent event or chat mount for discovery, and discovered thread syncs live for the desktop host's lifetime. A close for an undiscovered preexisting thread can still leave old cached tabs after chat unmounts; this predates this fix and is outside its discovery scope. macOS, Windows, iOS, Android, packaged Electron, and remote/relay/tunnel flows were not verified. Web and mobile do not mount this Electron-only host; provider adapters and wire contracts are unchanged.
Maintainer work: Codex harness, gpt-6.1-sol; fresh tests: Codex gpt-6-astra; reviews: Codex gpt-6-sol and Claude claude-opus-5-5.
Warning
Review limit reached#
Only developers with an assigned seat can use this organization's usage-based review budget, and seats here are assigned manually. Ask an admin to assign a seat, or change the review continuation mode in Billing.
Next included review available in 23 minutes.
Check out review usage here.
View limit details
Limit details: You’ve used all 10 included reviews currently available.
Learn how review limits work.
Review configuration:
⚙️ Run configuration
a09cbff6-364a-40c3-bd70-37a851797006📥 Commits
Reviewing files that changed from the base of the PR and between 68c1401c7658857110ef8660cc904778c37d2895 and 5a16f179fb4f56aa8827763ea9c49698f6112bb6.
📒 Files selected for processing: 5
apps/web/src/browser/ElectronBrowserHost.tsxapps/web/src/components/preview/previewSessionSync.browser.test.tsapps/web/src/components/preview/usePreviewSession.tspackages/client-runtime/src/state/preview.tspackages/client-runtime/src/state/runtime.test.tsNo actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
d693419d-3897-46ab-91ac-a54011a65fc0📥 Commits
Reviewing files that changed from the base of the PR and between a357bf832b381aad01b245ab3b9ade0444cdda45 and 68c1401c7658857110ef8660cc904778c37d2895.
📒 Files selected for processing: 5
apps/web/src/browser/ElectronBrowserHost.tsxapps/web/src/components/preview/previewSessionSync.browser.test.tsapps/web/src/components/preview/usePreviewSession.tspackages/client-runtime/src/state/preview.tspackages/client-runtime/src/state/runtime.test.tsIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
📝 Walkthrough
The runtime publishes preview events individually. In Electron, the host starts environment-scoped synchronization for threads discovered in preview events.
Changes: Desktop preview sessions
packages/client-runtime/src/state/preview.ts,packages/client-runtime/src/state/runtime.test.tsapps/web/src/components/preview/usePreviewSession.ts,apps/web/src/browser/ElectronBrowserHost.tsx,apps/web/src/components/preview/previewSessionSync.browser.test.tsElectronBrowserHostcalls the hook with the primary environment ID. Browser tests cover opened, list, and closed events.Priority: ⬇️ Low
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix
Sequence Diagram(s)#
Suggested reviewers:
juliusmarmingeMerge Risk: ⚪ Minimal · up to
68c14Background desktop preview attachment has no identified merge-blocking issue; normal checks remain appropriate.
Security architecture risk: 🔵 Low · up to
68c14Background previews can now start without opening their chats. Existing environment scoping and preview permissions remain in place, and no permission bypass was established. Cleanup across environment changes and packaged desktop behavior remain partly unverified.
Retained concerns No architecture-level concerns identified.
Security review details
Security Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
Pre-merge checks:
4
Full details: Description check
Explanation
The description explains the problem, implementation, verification, limitations, and affected platforms. It is mostly complete, although it does not explicitly document maintainer approval or explain why the fix qualifies without prior approval.
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment `@coderabbitai help` to get the list of available commands.