Repository navigation
perf(sleep): park idle agents in the worktree you are working in (#16211) - #16591
Merged
Merged
Conversation
nwparker
force-pushed
the
nwparker/win-16211-hibernate-active-worktree
branch
from
August 26, 2026 09:40
5d4d6d0 to
c215861
Compare
2 tasks done
The planner skipped the entire activeWorktreeId, so the tree a user actually works in never parked anything — exactly where a 16 GB Windows host accumulates its idle Codex/Grok panes and starts hard-paging (#16211). The two guards that remain are the correct granularity and already existed: foregroundTerminalTabIds covers the tab on screen, and the foregroundTerminalLastSeenAtByTabId floor in getEligiblePane holds any tab left inside the idle window. Test lever taken from @sanshengai's #16214, which found this first: pinning the existing sibling-tab regression to activeWorktreeId means it fails against the pre-fix planner. A standalone background-worktree case does not, because the fixture's active worktree is a different one — that is why the first cut of this change shipped a vacuous test. #16214 changed only the planner suite; the same one-line change also breaks agent-hibernation-coordinator's two revalidation tests, which used activeWorktreeId as their eligibility lever. Those now flip setForegroundTerminalTabIds instead, which is the property they were written to prove. Co-authored-by: sanshengai <[email protected]>
nwparker
marked this pull request as ready for review
August 26, 2026 10:11
nwparker
force-pushed
the
nwparker/win-16211-hibernate-active-worktree
branch
from
August 26, 2026 10:11
c215861 to
9de1fbb
Compare
5 tasks done
dallascrilley
pushed a commit
to dallascrilley/orca
that referenced
this pull request
Aug 27, 2026
…blyai#16591) The planner skipped the entire activeWorktreeId, so the tree a user actually works in never parked anything — exactly where a 16 GB Windows host accumulates its idle Codex/Grok panes and starts hard-paging (stablyai#16211). The two guards that remain are the correct granularity and already existed: foregroundTerminalTabIds covers the tab on screen, and the foregroundTerminalLastSeenAtByTabId floor in getEligiblePane holds any tab left inside the idle window. Test lever taken from @sanshengai's stablyai#16214, which found this first: pinning the existing sibling-tab regression to activeWorktreeId means it fails against the pre-fix planner. A standalone background-worktree case does not, because the fixture's active worktree is a different one — that is why the first cut of this change shipped a vacuous test. stablyai#16214 changed only the planner suite; the same one-line change also breaks agent-hibernation-coordinator's two revalidation tests, which used activeWorktreeId as their eligibility lever. Those now flip setForegroundTerminalTabIds instead, which is the property they were written to prove. Co-authored-by: sanshengai <[email protected]>
rahuljangirworks
pushed a commit
to rahuljangirworks/veer
that referenced
this pull request
Aug 27, 2026
…blyai#16591) The planner skipped the entire activeWorktreeId, so the tree a user actually works in never parked anything — exactly where a 16 GB Windows host accumulates its idle Codex/Grok panes and starts hard-paging (stablyai#16211). The two guards that remain are the correct granularity and already existed: foregroundTerminalTabIds covers the tab on screen, and the foregroundTerminalLastSeenAtByTabId floor in getEligiblePane holds any tab left inside the idle window. Test lever taken from @sanshengai's stablyai#16214, which found this first: pinning the existing sibling-tab regression to activeWorktreeId means it fails against the pre-fix planner. A standalone background-worktree case does not, because the fixture's active worktree is a different one — that is why the first cut of this change shipped a vacuous test. stablyai#16214 changed only the planner suite; the same one-line change also breaks agent-hibernation-coordinator's two revalidation tests, which used activeWorktreeId as their eligibility lever. Those now flip setForegroundTerminalTabIds instead, which is the property they were written to prove. Co-authored-by: sanshengai <[email protected]>
paidaxingyo666
pushed a commit
to paidaxingyo666/Manta
that referenced
this pull request
Aug 28, 2026
…blyai#16591) The planner skipped the entire activeWorktreeId, so the tree a user actually works in never parked anything — exactly where a 16 GB Windows host accumulates its idle Codex/Grok panes and starts hard-paging (stablyai#16211). The two guards that remain are the correct granularity and already existed: foregroundTerminalTabIds covers the tab on screen, and the foregroundTerminalLastSeenAtByTabId floor in getEligiblePane holds any tab left inside the idle window. Test lever taken from @sanshengai's stablyai#16214, which found this first: pinning the existing sibling-tab regression to activeWorktreeId means it fails against the pre-fix planner. A standalone background-worktree case does not, because the fixture's active worktree is a different one — that is why the first cut of this change shipped a vacuous test. stablyai#16214 changed only the planner suite; the same one-line change also breaks agent-hibernation-coordinator's two revalidation tests, which used activeWorktreeId as their eligibility lever. Those now flip setForegroundTerminalTabIds instead, which is the property they were written to prove. Co-authored-by: sanshengai <[email protected]> (cherry picked from commit e2cb797)
enrick-dev
pushed a commit
to enrick-dev/orca
that referenced
this pull request
Oct 15, 2026
…blyai#16591) The planner skipped the entire activeWorktreeId, so the tree a user actually works in never parked anything — exactly where a 16 GB Windows host accumulates its idle Codex/Grok panes and starts hard-paging (stablyai#16211). The two guards that remain are the correct granularity and already existed: foregroundTerminalTabIds covers the tab on screen, and the foregroundTerminalLastSeenAtByTabId floor in getEligiblePane holds any tab left inside the idle window. Test lever taken from @sanshengai's stablyai#16214, which found this first: pinning the existing sibling-tab regression to activeWorktreeId means it fails against the pre-fix planner. A standalone background-worktree case does not, because the fixture's active worktree is a different one — that is why the first cut of this change shipped a vacuous test. stablyai#16214 changed only the planner suite; the same one-line change also breaks agent-hibernation-coordinator's two revalidation tests, which used activeWorktreeId as their eligibility lever. Those now flip setForegroundTerminalTabIds instead, which is the property they were written to prove. Co-authored-by: sanshengai <[email protected]>
3 tasks
7 of 9 tasks
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.
ELI5
Orca can put idle, finished agent panes to sleep to save memory. It was skipping every pane in the worktree you're currently looking at — including background tabs you haven't touched in hours. On a 16 GB Windows machine that's exactly where the memory piles up. Now only the tab actually on screen (and one you left recently) is protected.
What Changed
Removed
worktreeId === snapshot.activeWorktreeIdfrom the planner's skip condition, so the existing per-tab foreground guard applies to every worktree.Why
planAgentHibernationCandidatesskipped the whole active worktree:The reporter in #16211 keeps four long-lived product worktrees with 1–3 agent tabs each and works in one of them. Sibling-tab idle already worked for the inactive trees; the active one — the one accumulating idle Codex/Grok panes and their MCP descendants — was exempt wholesale.
Removing it is safe because the two remaining guards are the more precise boundary and both already existed:
foregroundTerminalTabIdscovers the tab on screen, and theforegroundTerminalLastSeenAtByTabIdfloor ingetEligiblePaneis anchored to the end of a foreground visit, so a tab left inside the idle window cannot be parked. Everything else ingetEligiblePaneis untouched.Linked Issue
Addresses #16211 (the hibernation half). The diagnostics half is #16589.
Visual Proof
N/A — no UI change. Behaviour is a background scheduler decision; covered by unit tests instead.
Testing
pnpm test src/renderer/src/lib src/renderer/src/store→ 755 files / 7310 passed.pnpm tcclean.I manually tested these changes locally
Automated tests added/updated
Review
Two review findings, both material, and together they change my recommendation:
1. A repo-wide
pnpm formathad leaked into this commit — 32 files touched for a 6-file change, rewriting three canonical skill guides without regenerating their bundled artifacts. Confirmed P1 under adversarial verification. Fixed: the branch is rebuilt onorigin/mainas a single 6-file commit.2. My added tests were vacuous. They used worktree
wt-bgwhile the fixture'sactiveWorktreeIdwaswt-active, so the worktree was never the active one and the tests passed unchanged against pre-fix code. Worse, I had removedactiveWorktreeIdfrom the planner snapshot — which makes the pre-fix condition impossible to express in a test at all.@sanshengai's #16214 does this correctly and did it first. Same one-line planner change, but it keeps
activeWorktreeIdon the snapshot and sets it to the worktree under test inside the existing sibling-tab regression — one added line, and it genuinely fails against pre-fix code. That is smaller and strictly stronger than what I wrote.So: merge #16214, close this. If the now-dead
activeWorktreeIdfield is worth removing, that belongs in a separate follow-up after a non-vacuous test exists — not bundled with the behaviour change that needs it.Credit: @sanshengai identified and fixed this exact root cause first in #16214, against issue #16211's own proposed slice 3. They are also working the same #16211 umbrella from the orchestration side in #16217 (auto-releasing completed worker terminals), which is complementary and fills a gap none of my PRs address.