Repository navigation
test(session): guard against workspace-reopen tab fork-bomb (STA-1111) - #10057
Conversation
Relates to STA-1111 (already fixed on main by #6945). The runaway-tab-on-reopen bug was fixed by #6945 (activeOrQueuedResumeClaimsProviderSession dedup guard) hours before the ticket was filed. Verified: disabling that guard makes tab count climb 1->2->3->4 across reopens; restoring it holds at 1. This adds a revert-sensitive regression test covering the created-agent and sleeping-resume reopen paths so it cannot regress. Test plan: 2 new tests pass; fail if the #6945 guard is removed.
📝 WalkthroughWalkthroughAdds a Vitest regression test for STA-1111. It creates isolated Zustand state for one worktree, repeatedly injects sleeping Codex sessions, activates the worktree, and verifies that one tab is retained, the resumed session is associated with the tab, sleeping-session entries are cleared, and the first resume command references the same provider session. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: f6ac244c-ad8d-4fad-be61-ad25460c1a5c
📒 Files selected for processing (1)
src/renderer/src/lib/worktree-reactivation-tab-forkbomb.test.ts
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/renderer/src/lib/worktree-reactivation-tab-forkbomb.test.ts (1)
56-97: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winSolid regression coverage; consider also asserting tab-identity stability across reopens.
The loop only asserts
tabs.length === 1each iteration, not that it's the same tab reused across reopens. Capturing the tab id after the first iteration and asserting it doesn't change would make the test more robust against a regression where the tab is torn down and recreated each reopen (count stays 1, but identity churns).♻️ Optional strengthening
+ let stableTabId: string | undefined for (let reopen = 0; reopen < 4; reopen++) { ... const tabs = state.tabsByWorktree[worktree.id] ?? [] expect(tabs).toHaveLength(1) + stableTabId ??= tabs[0]!.id + expect(tabs[0]!.id).toBe(stableTabId) expect(state.automaticAgentResumeClaimsByTabId[tabs[0]!.id]?.providerSession).toEqual(
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 09b15c23-44eb-4c5f-930a-0bbea84a5a11
📒 Files selected for processing (1)
src/renderer/src/lib/worktree-reactivation-tab-forkbomb.test.ts
stablyai#10057) * test(session): guard against workspace-reopen tab fork-bomb (STA-1111) Relates to STA-1111 (already fixed on main by stablyai#6945). The runaway-tab-on-reopen bug was fixed by stablyai#6945 (activeOrQueuedResumeClaimsProviderSession dedup guard) hours before the ticket was filed. Verified: disabling that guard makes tab count climb 1->2->3->4 across reopens; restoring it holds at 1. This adds a revert-sensitive regression test covering the created-agent and sleeping-resume reopen paths so it cannot regress. Test plan: 2 new tests pass; fail if the stablyai#6945 guard is removed. * test(session): isolate automatic resume replay coverage * test(session): assert resumed tab identity stays stable
Summary
Adds a revert-sensitive regression test for STA-1111. The production fix merged the same day in #6945 after the user report; this PR protects that fix against regression.
Repeated workspace activation can receive a fresh sleeping-session record for the same Codex provider session. The test verifies that the first record resumes once and later replays are cleared instead of creating or replacing terminal tabs.
Test design
Screenshots
Not applicable; test-only change with no visual output.
Testing
AI Review Report
CodeRabbit identified the created-agent masking issue, addressed in 60afd27, and suggested stable tab identity coverage, added in 3188a11. The test uses platform-safe paths and exercises the runtime claim after startup consumption.
Cross-platform review: macOS, Linux, and Windows behavior is identical because the test uses path.join and does not touch shortcuts, shortcut labels, shell commands, Electron APIs, or host-specific runtime paths.
Security Audit
Test-only state setup and assertions; no production inputs, privileges, network behavior, persistence, or dependency changes.
Notes
No runtime code changes; no startup, interaction, polling, subprocess, memory, or renderer performance path is altered.