Skip to content

test(session): guard against workspace-reopen tab fork-bomb (STA-1111) - #10057

Merged
brennanb2025 merged 3 commits into
mainfrom
brennanb2025/sta1111-infinite-tabs
Jul 24, 2026
Merged

brennanb2025 merged 3 commits into
mainfrom
brennanb2025/sta1111-infinite-tabs

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Removes createdWithAgent from the fixture so created-agent startup cannot mask a broken sleeping-session resume.
  • Consumes the first queued startup command, then repeats activation with newly captured records for the same provider session.
  • Verifies the resumed tab owns the exact provider-session claim, replay records are cleared, tab count remains one, and tab identity stays stable across four activations.
  • Revert check: removing activeOrQueuedResumeClaimsProviderSession makes the test fail on the second activation with two tabs.

Screenshots

Not applicable; test-only change with no visual output.

Testing

  • 51 related Vitest tests across regression, automatic-resume replay, sleeping-session resume, and created-agent activation suites.
  • Touched-file oxlint and oxfmt checks.
  • git diff --check.

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.

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.
@coderabbitai

coderabbitai Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds 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)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title is concise and accurately describes the main change: a regression test guarding against the workspace-reopen tab fork-bomb.
Description check ✅ Passed The description matches the template structure and includes summary, screenshots, testing, AI review, security audit, and notes with relevant details.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4fce2de and 5e71c9f.

📒 Files selected for processing (1)
  • src/renderer/src/lib/worktree-reactivation-tab-forkbomb.test.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/renderer/src/lib/worktree-reactivation-tab-forkbomb.test.ts (1)

56-97: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Solid regression coverage; consider also asserting tab-identity stability across reopens.

The loop only asserts tabs.length === 1 each 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

📥 Commits

Reviewing files that changed from the base of the PR and between 5e71c9f and 60afd27.

📒 Files selected for processing (1)
  • src/renderer/src/lib/worktree-reactivation-tab-forkbomb.test.ts

@brennanb2025
brennanb2025 merged commit ec04827 into main Jul 24, 2026
1 check passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant