Skip to content

fix: keep dashboard importable without Unix PTY modules - #21770

Closed
bgmbgm94 wants to merge 2 commits into
NousResearch:mainfrom
bgmbgm94:fix/windows-dashboard-pty-import
Closed

fix: keep dashboard importable without Unix PTY modules#21770
bgmbgm94 wants to merge 2 commits into
NousResearch:mainfrom
bgmbgm94:fix/windows-dashboard-pty-import

Conversation

@bgmbgm94

@bgmbgm94 bgmbgm94 commented May 8, 2026

Copy link
Copy Markdown

Summary

Native Windows is documented as an early-beta runtime, but the dashboard /chat embedded terminal path is still the main native-Windows gap because it depends on POSIX PTY primitives. This PR keeps the rest of the dashboard usable and makes the /chat failure mode friendlier while testing there:

  • Guard Unix-only fcntl and termios imports in hermes_cli.pty_bridge
  • Keep hermes_cli.web_server importable when PTY support is unavailable
  • Preserve existing Linux/macOS behavior: PtyBridge.is_available() remains true only when ptyprocess, fcntl, and termios are all available and the platform is not native Windows
  • Add a regression test that simulates missing Unix PTY modules and verifies non-PTY dashboard routes can still import while PTY spawn reports unavailable
  • Strengthen the embedded-chat WebSocket test so PTY unavailability sends a clear message and closes the socket instead of crashing the dashboard server

Related to #5246 and complements #5247. That PR covers tools/memory_tool.py plus guarded SIGKILL lookups; this PR covers the dashboard chat PTY bridge import path, which is a separate fcntl/termios import site.

Testing

  • python -m pytest tests/hermes_cli/test_web_server.py::TestNativeWindowsPtyImportFallback::test_web_server_imports_when_unix_pty_modules_are_missing tests/hermes_cli/test_web_server.py::TestPtyWebSocket -q -o addopts=
    • 12 passed
  • python -m pytest tests/hermes_cli/test_web_server.py -q -o addopts=
    • 138 passed
  • ruff check hermes_cli/pty_bridge.py tests/hermes_cli/test_web_server.py
    • All checks passed!
  • Native Windows Python smoke via the Hermes Windows venv:
    • platform= win32
    • fcntl= None
    • termios= None
    • pty_available= False
    • web_server_app= True

Note: I could not run the pytest target inside the Windows Hermes venv because that venv does not have pytest installed. The Linux/WSL venv ran the regression suite above, and the native Windows Python smoke directly verified this import path with missing fcntl/termios.

@alt-glitch alt-glitch added type/bug Something isn't working comp/cli CLI entry point, hermes_cli/, setup wizard P3 Low — cosmetic, nice to have labels May 8, 2026
@bgmbgm94
bgmbgm94 force-pushed the fix/windows-dashboard-pty-import branch from 51ae744 to bebf18e Compare May 8, 2026 12:05
@austinpickett
austinpickett requested a review from Copilot May 8, 2026 20:26

Copilot AI 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.

Pull request overview

Improves the dashboard’s robustness on native Windows / non-POSIX environments by making the PTY bridge optional at import-time, so hermes_cli.web_server can still load and serve non-PTY routes even when Unix PTY modules aren’t present.

Changes:

  • Guard fcntl / termios imports in hermes_cli.pty_bridge and make PTY availability depend on ptyprocess + fcntl + termios + non-Windows platform.
  • Add a regression test ensuring hermes_cli.web_server remains importable when Unix PTY modules are missing and that PTY spawn reports unavailable.
  • Strengthen the /api/pty WebSocket test to assert the endpoint sends an error message and then closes cleanly when PTY spawn is unavailable.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
hermes_cli/pty_bridge.py Makes Unix-only dependencies optional at import-time and refines the PTY availability gate.
tests/hermes_cli/test_web_server.py Adds regression coverage for missing Unix PTY modules and tightens WebSocket failure-mode assertions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread hermes_cli/pty_bridge.py
Comment on lines +52 to 59
_PTY_AVAILABLE = (
ptyprocess is not None
and fcntl is not None
and termios is not None
and not sys.platform.startswith("win")
)


Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks, agreed — the unavailable path should keep the graceful import behavior but still surface an actionable spawn-time reason. I'll update the spawn error to distinguish native Windows from missing Unix PTY modules and add regression coverage for that message.

@teknium1

teknium1 commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Closing as superseded by #42251, which adds an actual ConPTY backend (hermes_cli/win_pty_bridge.py) rather than only guarding the import. The graceful-degradation idea was right — your PR was the first to make the dashboard's non-chat tabs survive a POSIX-only-pty_bridge import on Windows — but the real fix is to make the chat tab itself work, which #42251 does. Thanks for the early push on this.

Copy link
Copy Markdown
Author

Thanks for the clear explanation and for carrying the Windows dashboard fix forward in #42251. Agreed that the ConPTY backend is the right final shape here, so I’m closing this as superseded.

@bgmbgm94 bgmbgm94 closed this Jun 11, 2026
@bgmbgm94

Copy link
Copy Markdown
Author

Thanks for the clear explanation and for carrying the Windows dashboard fix forward in #42251. Agreed that the ConPTY backend is the right final shape here, so I’m closing this as superseded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants