Skip to content

Add support for terminal related methods in web socket connection#32

Merged
veithly merged 1 commit intomasterfrom
feat/term_methods
Mar 12, 2026
Merged

Add support for terminal related methods in web socket connection#32
veithly merged 1 commit intomasterfrom
feat/term_methods

Conversation

@joeqian10
Copy link
Contributor

Summary

Add runtime-backed terminal session support to the websocket gateway by implementing term.open, term.input, term.resize, and term.close in spoon-bot.

Changes

  • add websocket protocol enums for terminal RPC methods and terminal-related events
  • implement WorkspaceTerminalService to manage connection-scoped terminal sessions inside the runtime workspace
  • support opening shells with configurable cwd, shell, cols, rows, and env
  • stream terminal output back to clients via sandbox.stdout
  • emit terminal lifecycle completion via term.closed
  • support terminal resize and explicit close requests
  • clean up terminal sessions automatically when the websocket connection closes
  • add service-level tests covering open/input/close, resize, and workspace boundary validation

Why

The API layer already forwards term.* methods and normalizes terminal events, but the runtime did not actually provide terminal sessions. This PR closes that gap so the frontend can use interactive sandbox terminals instead of relying on mocked behavior or unsupported methods.

Validation

  • python -m py_compile spoon_bot/gateway/websocket/workspace_terminal.py spoon_bot/gateway/websocket/handler.py spoon_bot/gateway/websocket/protocol.py tests/test_workspace_terminal_service.py
  • manual local runtime check covering term.open -> term.input -> sandbox.stdout -> term.closed

Notes

  • terminal sessions are connection-scoped and are not resumable
  • the implementation uses PTY on POSIX runtimes and a pipe-based fallback for non-POSIX local development

@veithly veithly merged commit f6c6ac3 into master Mar 12, 2026
1 of 2 checks passed
@joeqian10 joeqian10 deleted the feat/term_methods branch March 12, 2026 07:45
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.

2 participants