fix(preview): keep desktop-rendered tabs out of idle cleanup #18147
main fromrefs/pull/18147/head·merged by juliusmarminge View on GitHubDesktop-rendered agent tabs have no streamed viewers, and the server does not see the user reading or interacting with their webview. Idle cleanup could therefore close a tab while the user was reading it.
Exclude desktop-rendered tabs from the idle sweep. Unwatched headless tabs remain eligible for cleanup, and users can still close desktop tabs normally. The desktop tab strip retains its existing lifetime ownership; no workflow or setting is added.
Credit to @TDanks2000 for #18147, originally split from #17871. The takeover merges current main without rewriting contributor commits and retains the single behavior regression in the existing ServerBrowser.test.ts.
Both independent round-one reviews found no code blockers. The exemption applies to tabs already attached to the desktop. A pre-existing late-attach path can leave the server tab headless; adoption of that page remains outside this change. Retained desktop tabs continue to count toward existing tab limits until closed.
Verification and limits#
- PR regression coverage: 1 test → 1 test, covering both desktop retention and headless cleanup through broker operations and observable sessions.
- Removing only the desktop exclusion makes that test fail; restoring it makes all 43 ServerBrowser tests pass.
- Scoped lint, formatting, and server typecheck pass. The first wrapper-based typecheck did not run because concurrent automatic dependency preparation hit a git config lock; invoking the package’s exact typecheck command directly succeeded.
- This is shared server lifecycle behavior, reached by browser automation and normal preview operations. No client, transport, or provider schema changes are needed.
No live desktop or browser verification was possible on this headless Linux host: T3’s Browser panel could not start because Chromium system libraries are missing. The service tests use the established browser/desktop fixtures; they are not an Electron lifetime demonstration. macOS, Windows, iOS, Android, and Electron desktop were not verified during this takeover. Fresh integrated lifetime evidence remains a human verification gate.
Tests: GPT-6 Astra; implementation: GPT-6.1 Sol; reviews: Claude Opus 5.5 and GPT-6 Sol. Codex harness in T3 Code (Claude review via Claude Code).
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
Approvability#
Verdict: Approved at
339d94cMacroscope's review found this PR approvable — This narrowly scoped fix prevents desktop-rendered preview tabs from being removed by headless idle cleanup while preserving cleanup for inactive headless tabs. A focused regression test covers the behavior without introducing new capabilities, defaults, or sensitive changes.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).juliusmarminge added labelsmacroscope-review
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
-
⚙️ Run configuration
-
- Configuration used: Path: .coderabbit.config.ts
- Review profile: CHILL
- Plan: Advanced
- Run ID:
6b851825-b4e5-4137-b108-587b725d2623
📥 Commits
-
Reviewing files that changed from the base of the PR and between 8d199b4f7b918079161d5f43e0146c099301be08 and 273d7cc44df348216d38cede1a4ac042600597f6.
📒 Files selected for processing (2)
-
apps/server/src/preview/ServerBrowser.test.tsapps/server/src/preview/ServerBrowser.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
-
📝 Walkthrough
-
Idle cleanup now leaves desktop-rendered agent tabs open. A regression test checks that an unwatched headless tab is removed after the idle threshold while the desktop-rendered tab and a newly opened tab remain.
Changes: Idle tab cleanup
Layer / File(s) Summary Desktop tab exclusion and regression coverage
apps/server/src/preview/ServerBrowser.ts,apps/server/src/preview/ServerBrowser.test.tscloseIdleAgentTabsskips tabs rendered on the desktop. The test checks tab retention and cleanup after 31 minutes.Priority: ⬇️ Low
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Suggested reviewers:
juliusmarminge
### Architecture SummaryMerge Risk: ⚪ Minimal · up to
273d7-
Idle cleanup continues to remove stale headless tabs while preserving desktop-rendered tabs, and the regression test covers both outcomes. No concrete merge-blocking failure is established.
Architecture risk: 🟡 Medium · up to
273d7The change affects 1 system.
Changed systems:
apps/serverArchitecture concerns No architecture-level concerns identified.
Review details
-
Systems and components
- observed — apps/server (service) was modified; 2 changed files map to changed impact.
Before / after behavior
- observed — Modified behavior in apps/server/src/preview/ServerBrowser.test.ts: Added a regression test for idle-tab cleanup: after 31 minutes, opening another tab retains the desktop-rendered tab and the new tab but removes the unwatched headless tab.
- observed — Modified behavior in apps/server/src/preview/ServerBrowser.ts:
closeIdleAgentTabsnow documents the desktop-tab case and addstab.desktop === nullto the close condition. Unwatched agent tabs older than the cutoff are closed only when they are not desktop-rendered.
Reliability and maintainability
- inferred — Risk-relevant change factors for apps/server: blast_radius_1; direct_dependents_1
Pre-merge checks:
4-
Check name Status Explanation Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check skipped because no linked issues were found for this pull request. Title check The title clearly and concisely describes the main change: excluding desktop-rendered tabs from preview idle cleanup. Description check The description covers the problem, change, scope, approval context, verification results, and known verification limits. It does not use the template's exact section headings, but it provides the req… Full details: Description check
-
Explanation
The description covers the problem, change, scope, approval context, verification results, and known verification limits. It does not use the template's exact section headings, but it provides the required information and is sufficiently complete.
-
✨ Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
-
coderabbitai[bot](GitHub profile, opens in a new tab) approved these changes
juliusmarminge assignedjuliusmarminge
Taking over this one for terminal-preview-05. I’ll resolve the conflicts with main, keep the desktop/headless lifetime distinction, and push the focused result to this branch.
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:S
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XS
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
juliusmarminge merged this53ca474
juliusmarminge closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed