?
APLANE-27
feature,backend
Created: 2025-12-25 Updated: 2025-12-25
Relationships Loading...
Attachments
Loading...
Comments (4)
qa-agent · 2025-12-25
## QA PASSED (Round 2) See QA report document: 844fbcbd-75e5-482e-b0a3-8e179a05bcdd **Tests performed:** - Wrapper script approach verified - Session URL capture verified - Session persistence verified (>90 seconds, no immediate EOF) - Interactivity verified via tmux send-keys - Cleanup verified (tmux killed, tty-share closed) **Key evidence:** - tty-proxy logs show session persisting without immediate EOF - Multiple front clients successfully connected and proxied content - Agent cleanup properly closes tty-share session **Limitation:** No browser available for UI testing - verified via API/logs only. The --no-wait and --listen :0 flags combined with the wrapper script approach successfully fix the immediate session exit bug.
agent · 2025-12-25
## Fix Implemented ### Root Cause The original fix with --no-wait and --listen :0 was correct for tty-share behavior, but there were additional issues: 1. **Shell quoting problems**: The nested single/double quotes in the command line were breaking the shell parsing 2. **PTY interference**: Using subprocess.PIPE for stdout was interfering with the PTY that script -q /dev/null -c ... creates 3. **Process lifecycle**: The tty-share process needed to be properly detached from the Python process ### Solution Applied Changed start_tty_share_for_tmux() in /home/gateway/gitea/agent-plane/backend/services/screen_manager.py: 1. **Wrapper script approach**: Instead of trying to quote the command correctly, we now create a wrapper shell script that contains the tty-share command 2. **File-based output capture**: Instead of using subprocess.PIPE (which interferes with PTY), redirect output to a temp file and poll it for the session URL 3. **Background process detachment**: Use start_new_session=True and shell background (&) to properly detach tty-share ### Key flags added to tty-share command: - --no-wait: Don't wait for Enter key (tty-share v2.4.1 waits by default) - --listen :0: Use random port for local listener (avoids port 8000 conflict with FastAPI) - TERM=xterm-256color: Proper terminal type for color support ### Verification - Agent launched with ttyShareUrl populated correctly - tty-share session persists (no immediate EOF) - Front clients can connect and receive proxied content - tmux session remains active and attached
qa-agent · 2025-12-25
## QA FAILED See QA report document: c21e4f0b-fa21-4009-ada7-56da1713bd68 **Critical Bug Found:** tty-share sessions exit immediately after startup **Root Cause:** Missing required flags in tty-share command: - `--no-wait` - tty-share waits for Enter key by default - `--listen :0` - avoids port 8000 conflict with FastAPI **Evidence:** - tty-proxy logs show sessions closing immediately: 'tty-share session ... closed: EOF' - Manual testing confirms tty-share outputs 'Press Enter to continue!' then exits **Fix Required in screen_manager.py:** Change: ```python tty_share_inner_cmd = f'tty-share --tty-proxy {TTY_SHARE_SERVER} --public --no-tls --command tmux --args ...' ``` To: ```python tty_share_inner_cmd = f'tty-share --tty-proxy {TTY_SHARE_SERVER} --public --no-tls --no-wait --listen :0 --command tmux --args ...' ``` Also set TERM=xterm-256color environment variable. Returning to todo for fixes.
agent · 2025-12-25
## Implementation Complete ### Changes Made **1. Dockerfile** (/home/gateway/gitea/agent-plane/backend/Dockerfile): - Added wget to runtime dependencies - Added tty-share v2.4.1 binary installation from GitHub releases **2. config.py** (/home/gateway/gitea/agent-plane/backend/config.py): - Added TTY_SHARE_SERVER config (default: tty-proxy.roboalch.com:3456) - Added TTY_PROXY_PUBLIC_URL config (default: https://tty-proxy.roboalch.com) - Removed TTYD_BASE_URL config **3. screen_manager.py** (/home/gateway/gitea/agent-plane/backend/services/screen_manager.py): - Replaced build_terminal_url() to work with session IDs instead of ports - Added extract_session_id_from_url() helper function - Created start_tty_share_for_tmux() function to launch tty-share with PTY allocation - Updated create_screen() to use tty-share instead of ttyd - Made restart_ttyd_with_new_font_size() and kill_ttyd_process() backward-compatible no-ops **4. main.py** (/home/gateway/gitea/agent-plane/backend/main.py): - Changed use_ttyd=True to use_tty_share=True in agent launch and extra terminal launch **5. docker-compose.yml** (/home/gateway/setup/aplane/docker-compose.yml): - Added TTY_SHARE_SERVER=host-gateway:3456 (uses Docker host-gateway for container-to-host comms) - Added TTY_PROXY_PUBLIC_URL=https://tty-proxy.roboalch.com - Added extra_hosts mapping for host-gateway ### Key Technical Details - tty-share requires a real PTY to function, so we use script -q /dev/null -c ... to allocate one - The --no-tls flag is required because the backend connection to tty-proxy is unencrypted - tty-share requires --command and --args as separate parameters (not combined) - Terminal URLs are now session-based (e.g., https://tty-proxy.roboalch.com/s/{session-id}/) instead of port-based ### Verification - Deployed to production and tested agent launch - ttyShareUrl is populated with valid session URL - Session URL returns HTTP 200 - Agent cleanup works correctly