hermes - ✅(Solved) Fix [Bug]: terminalSetup tests fail on SSH-connected machines due to env leakage [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#18939Fetched 2026-05-03 04:53:25
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Timeline (top)
labeled ×3commented ×1cross-referenced ×1

Root Cause

9 of 20 tests in terminalSetup.test.ts fail with:

Expected: true
Received: false

Because isRemoteShellSession(env) returns true via process.env.

Fix Action

Fixed

PR fix notes

PR #18929: test(tui): isolate terminalSetup tests from SSH env

Description (problem / solution / changelog)

Summary

The terminalSetup.test.ts test suite fails on any machine where SSH_CONNECTION, SSH_TTY, or SSH_CLIENT is present in process.env. CI runners and developer workstations with active SSH sessions hit this, causing 9 spurious failures that have nothing to do with the keybinding logic being tested.

Problem

configureTerminalKeybindings contains an SSH guard (isRemoteShellSession) that short-circuits with success: false when SSH env vars are detected. In the existing tests, most configureTerminalKeybindings calls do not pass an explicit env option, so they fall back to process.env. On an SSH-ed machine, every one of those tests fails with the SSH message instead of exercising the actual keybinding logic.

Changes

  • ui-tui/src/__tests__/terminalSetup.test.ts:
    • Import beforeEach from vitest
    • Add a beforeEach hook inside the configureTerminalKeybindings describe block that stubs SSH_CONNECTION, SSH_TTY, and SSH_CLIENT to empty strings

This is minimal and targeted — the two existing SSH-specific tests (lines ~310 and ~379) already pass explicit env objects and remain correctly tested.

Verification

  • vitest run src/__tests__/terminalSetup.test.ts: 20/20 passed (was 9 failures before)
  • vitest run (full suite): 53/53 files passed, 548/548 tests passed

Scope: only affects test isolation. No application behavior changes.

Related

Fixes #18939

Changed files

  • ui-tui/src/__tests__/terminalSetup.test.ts (modified, +8/-1)

Code Example

Expected: true
Received: false
RAW_BUFFERClick to expand / collapse

Bug Description

The terminalSetup.test.ts test suite fails on any machine where SSH_CONNECTION, SSH_TTY, or SSH_CLIENT is present in process.env. This includes:

  • CI runners connected over SSH
  • Developer workstations with active SSH sessions
  • Any environment where SSH env vars leak into the test process

The configureTerminalKeybindings function has an isRemoteShellSession() guard that short-circuits with success: false when SSH vars are detected. Most tests in the suite do not pass an explicit env option, so they fall back to process.env and hit this guard instead of exercising the actual keybinding logic.

Steps to Reproduce

  1. Connect to a machine via SSH (or export SSH_CONNECTION=1)
  2. cd ui-tui && npm run test
  3. Observe 9 failures in terminalSetup.test.ts — all return the SSH short-circuit message instead of the expected keybinding result

Expected Behavior

Tests should be isolated from the host environment. The SSH guard should only affect the two tests explicitly testing SSH behavior, not the entire suite.

Actual Behavior

9 of 20 tests in terminalSetup.test.ts fail with:

Expected: true
Received: false

Because isRemoteShellSession(env) returns true via process.env.

Proposed Fix

Add a beforeEach hook in the configureTerminalKeybindings describe block that stubs SSH_CONNECTION, SSH_TTY, and SSH_CLIENT to empty strings using vi.stubEnv(). The two SSH-specific tests later in the file already pass explicit env objects and are unaffected.

See PR #18929 for the implementation.

extent analysis

TL;DR

To fix the test failures in terminalSetup.test.ts, stub the SSH environment variables in the test setup to prevent the isRemoteShellSession guard from short-circuiting.

Guidance

  • Identify the tests in terminalSetup.test.ts that are failing due to the SSH guard and verify that they are not passing an explicit env option.
  • Use a beforeEach hook to stub the SSH_CONNECTION, SSH_TTY, and SSH_CLIENT environment variables to empty strings using vi.stubEnv().
  • Review the two SSH-specific tests to ensure they are not affected by the stubbing, as they pass explicit env objects.
  • Run the tests again after applying the stubbing to verify that the failures are resolved.

Example

beforeEach(() => {
  vi.stubEnv('SSH_CONNECTION', '');
  vi.stubEnv('SSH_TTY', '');
  vi.stubEnv('SSH_CLIENT', '');
});

Notes

This fix assumes that the vi.stubEnv() function is available and correctly stubs the environment variables. If this function is not available, an alternative approach may be needed.

Recommendation

Apply the workaround by stubbing the SSH environment variables in the test setup, as this will isolate the tests from the host environment and prevent the isRemoteShellSession guard from interfering with the test results.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING