Skip to content

Conversation

@ibetitsmike
Copy link
Contributor

In server mode, there was a race condition where the shell prompt would be lost because the PTY started emitting output before the HTTP response (with session ID) returned and before the client registered its WebSocket handler.

The fix adds output buffering on the server side:

  • PTY output is buffered in the session until client subscribes
  • New TERMINAL_SUBSCRIBE IPC channel to signal readiness
  • Client calls subscribe after registering its output handler
  • Server flushes buffered output when subscribe is called

This ensures the initial shell prompt is always delivered to the terminal.

Generated with mux

In server mode, there was a race condition where the shell prompt would be
lost because the PTY started emitting output before the HTTP response
(with session ID) returned and before the client registered its WebSocket
handler.

The fix adds output buffering on the server side:
- PTY output is buffered in the session until client subscribes
- New TERMINAL_SUBSCRIBE IPC channel to signal readiness
- Client calls subscribe after registering its output handler
- Server flushes buffered output when subscribe is called

This ensures the initial shell prompt is always delivered to the terminal.

_Generated with `mux`_
@ibetitsmike ibetitsmike added this pull request to the merge queue Dec 1, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 1, 2025
@ibetitsmike ibetitsmike added this pull request to the merge queue Dec 1, 2025
github-merge-queue bot pushed a commit that referenced this pull request Dec 1, 2025
In server mode, there was a race condition where the shell prompt would
be lost because the PTY started emitting output before the HTTP response
(with session ID) returned and before the client registered its
WebSocket handler.

**The fix adds output buffering on the server side:**
- PTY output is buffered in the session until client subscribes
- New `TERMINAL_SUBSCRIBE` IPC channel to signal readiness
- Client calls subscribe after registering its output handler
- Server flushes buffered output when subscribe is called

This ensures the initial shell prompt is always delivered to the
terminal.

_Generated with `mux`_
github-merge-queue bot pushed a commit that referenced this pull request Dec 1, 2025
In server mode, there was a race condition where the shell prompt would
be lost because the PTY started emitting output before the HTTP response
(with session ID) returned and before the client registered its
WebSocket handler.

**The fix adds output buffering on the server side:**
- PTY output is buffered in the session until client subscribes
- New `TERMINAL_SUBSCRIBE` IPC channel to signal readiness
- Client calls subscribe after registering its output handler
- Server flushes buffered output when subscribe is called

This ensures the initial shell prompt is always delivered to the
terminal.

_Generated with `mux`_
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Dec 1, 2025
@ibetitsmike
Copy link
Contributor Author

Closing this PR as the issue has already been fixed on main via the ORPC refactor. The new TerminalService class in main uses an outputBuffers map to buffer terminal output and replays it when onOutput is called, fixing the race condition.

See src/node/services/terminalService.ts on main for the implementation.

Generated with mux

@ibetitsmike ibetitsmike closed this Dec 3, 2025
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