Skip to content

feat(sandbox): add terminal settings support for create_session API#541

Open
xdlkc wants to merge 3 commits intoalibaba:masterfrom
xdlkc:feat/terminal-settings
Open

feat(sandbox): add terminal settings support for create_session API#541
xdlkc wants to merge 3 commits intoalibaba:masterfrom
xdlkc:feat/terminal-settings

Conversation

@xdlkc
Copy link

@xdlkc xdlkc commented Feb 28, 2026

Summary

  • Add terminal settings support for CreateBashSessionRequest:
    • term: terminal type (default: dumb)
    • columns: terminal width (default: 80)
    • lines: terminal height (default: 24)
    • lang: language/encoding (default: en_US.UTF-8)
  • Set environment variables (TERM, COLUMNS, LINES, LANG) for bash session
  • Set pexpect `dimensions` parameter for proper `stty size` output

Problem

When `env_enable=False` (default), bash sessions lack terminal environment variables, causing:

  • Color output not working
  • Text editors (vim, nano) malfunctioning
  • CLI tools (htop, less) reporting errors
  • `stty size` returning 0 or invalid values

Solution

Parameter Type Default Description
`term` str `"dumb"` Terminal type (TERM)
`columns` int `80` Terminal width
`lines` int `24` Terminal height
`lang` str `"en_US.UTF-8"` Language/encoding (LANG)

Priority: `env` param > terminal params > inherited env > defaults

Test Plan

  • Default terminal values verified (TERM=dumb, LANG=en_US.UTF-8)
  • Custom terminal values verified
  • `stty size` output verified (returns correct dimensions)
  • `env` parameter override priority verified
  • All 8 tests in `test_local_sandbox_runtime.py` pass

fixes #540

@CLAassistant
Copy link

CLAassistant commented Feb 28, 2026

CLA assistant check
All committers have signed the CLA.

@xdlkc xdlkc force-pushed the feat/terminal-settings branch from 4fb32c4 to d162136 Compare February 28, 2026 11:14
@xdlkc xdlkc force-pushed the feat/terminal-settings branch from d162136 to 7c39e67 Compare February 28, 2026 11:22
Changed term and lang parameters to optional (str | None) with None as
default. This maintains backward compatibility by not setting TERM and
LANG environment variables unless explicitly specified by the user.

Key changes:
- term: str | None = None (was str = "dumb")
- lang: str | None = None (was str = "en_US.UTF-8")
- columns/lines: unchanged (default 80/24 for pexpect dimensions)
- Only set TERM/LANG env vars when user explicitly provides values
- Reverted _strip_control_chars to original (no \r stripping)
- Updated tests to reflect new behavior
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.

feat: add terminal settings support for create_session API

2 participants