Skip to content

test(ssh): clear SSH session holds between connection test files - #40673

Merged
nwparker merged 2 commits into
mainfrom
contrib/ssh-test-session-holds
Nov 10, 2026
Merged

nwparker merged 2 commits into
mainfrom
contrib/ssh-test-session-holds

Conversation

@nwparker

@nwparker nwparker commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Some SSH tests leave a "this host was disconnected" or "sign-in was cancelled" mark behind. When test files share a worker, the next file sees that mark and its SSH connections are refused. Unrelated tests then fail. This PR clears both marks before every test that could be affected.

Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​8 $\color{#cf222e}{\Huge{\mathbf{−}}}$​10 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​3 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​3

What Changed

  • ssh-connection-manager.test.ts now clears the credential-decline and user-disconnect stores before and after every case, not only in two describe blocks. This is gentslava's commit from test(ssh): isolate connection-manager session holds #40293, cherry-picked with authorship kept.
  • The shared SSH connection fixture reset (resetSshConnectionMocks) now clears credential declines too. test(ssh): reset user disconnect state in connection fixtures #40525 already made it clear user disconnects. Every suite built on the fixture now starts with no session holds. The per-suite resets this replaces, in sign-in-reuse and wake-retry, are removed.
  • No production code changes.

Why

The two hold stores are module-level state, so in the shared-worker test project they outlive a file. Resetting them in the victims (the manager suite and the shared fixture) covers every suite that reads them. Chasing each file that leaves a hold behind would miss future cases.

Linked Issue

Fixes #40291

Credit: gentslava reported #40291 and wrote #40293. AmethystLiang fixed the fixture side in #40525, which is merged.

Visual Proof

N/A: test-only change.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below
  • Every added test fails without this change and avoids the test anti-patterns

I simulated a leaked hold by seeding recordSshUserDisconnected('target-1') and recordSshCredentialDeclined('target-1') at module load in ssh-connection-manager.test.ts and ssh-connection-loopback-cancel.test.ts. On main, 9 tests fail. On this branch, all 12 pass. All 16 test files that import the fixture or the manager suite pass (77 tests). Typecheck and the static job pass.

Risk

Level: Low. Test-only. Back it out with a plain revert.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • I stated the risk: what could break, for whom, and how to back it out

gentslava and others added 2 commits November 9, 2026 22:58
…n fixture

The fixture reset now clears credential declines as well as user disconnects,
so every suite built on it starts without a stale hold from an earlier file in
the same worker. The per-suite resets it supersedes are removed.

Fixes #40291
@coderabbitai

coderabbitai Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The SSH connection test harness now resets credential-decline state when it resets connection mocks. The connection-manager test suite resets credential-decline and user-disconnect state before and after each test. Other SSH connection tests remove local reset calls.

Severity of issue fixed: Medium

Merge Risk: Minimal · up to 219d9

No actionable merge-blocking risk is identified in the SSH test setup changes.

Pre-merge checks: Passed 5

Check name Status Explanation
Title check Passed The title clearly summarizes the main change: clearing SSH session holds between connection test files.
Description check Passed The description covers the required change, reason, linked issue, visual proof, testing, risk, and agent-skill boundary. The AI disclosure is explicitly optional for internal contributors; the missing…
Linked Issues check Passed Issue #40291 requires every connection-manager test to start and end with clean credential-decline and user-disconnect state. The manager test file now resets both stores in top-level beforeEach and a…
Out of Scope Changes check Passed All changes support issue #40291 by centralizing test-state cleanup. The fixture reset covers other SSH suites that share the module-level state, and removal of duplicate per-suite resets preserves th…
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Full details: Description check

Explanation

The description covers the required change, reason, linked issue, visual proof, testing, risk, and agent-skill boundary. The AI disclosure is explicitly optional for internal contributors; the missing Review heading and some unchecked checklist items do not make the description incomplete.

Full details: Linked Issues check

Explanation

Issue #40291 requires every connection-manager test to start and end with clean credential-decline and user-disconnect state. The manager test file now resets both stores in top-level beforeEach and afterEach hooks. Existing assertions and production disconnect behavior remain unchanged. The shared fixture also resets both stores, so suites using it start without stale session holds.

Full details: Out of Scope Changes check

Explanation

All changes support issue #40291 by centralizing test-state cleanup. The fixture reset covers other SSH suites that share the module-level state, and removal of duplicate per-suite resets preserves that cleanup. The diff changes test code only and includes no unrelated production changes.

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 4 files.

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2218fb01-f04e-4e69-b982-028ad1a31217
Commits

Reviewing files that changed from the base of the PR and between 0d94676 and 219d9ba.

Files selected for processing: 4

  • src/main/ssh/connection/ssh-connection-manager-sign-in-reuse.test.ts
  • src/main/ssh/connection/ssh-connection-manager.test.ts
  • src/main/ssh/connection/ssh-connection-wake-retry.test.ts
  • src/main/ssh/connection/testing/ssh-connection-test-harness.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@nwparker
nwparker merged commit fedb28b into main Nov 10, 2026
59 checks passed
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.

Connection-manager shared-worker tests retain SSH session holds

2 participants