Skip to content

Fix copilot CLI session termination in web terminal#7

Draft
Copilot wants to merge 3 commits intomasterfrom
copilot/debug-copilot-cli-session
Draft

Fix copilot CLI session termination in web terminal#7
Copilot wants to merge 3 commits intomasterfrom
copilot/debug-copilot-cli-session

Conversation

Copy link

Copilot AI commented Mar 24, 2026

Copilot CLI sessions launched from the session picker were being destroyed when the copilot process exited, ejecting users back to the session picker. Long-running tasks also caused silent WebSocket disconnects due to nginx's default 60s proxy timeout.

Session persistence (session-picker.py)

Copilot was run as the direct initial tmux command — when the process exits (agent handoff, task phase completion, error), tmux destroys the window and session. Fix wraps the launch in a persistent shell:

# Before: session dies when copilot exits
os.execvp("tmux", ["tmux", "new-session", "-s", name, "copilot", "--continue"])

# After: copilot exits → user drops to zsh, session survives
os.execvp("tmux", ["tmux", "new-session", "-s", name,
                    "-c", "/home/agentbox/workspace",
                    "zsh", "-i", "-c", "copilot --continue; exec zsh"])

Applied to [c], [r], and c<N> (resume-by-id) options.

WebSocket keepalive (Dockerfile, session-manager.py, entrypoint.sh)

  • Added proxy_read_timeout 86400s / proxy_send_timeout 86400s to all nginx terminal locations (main /terminal/ and dynamically generated per-session configs)
  • Added --ping-interval 30 to all ttyd invocations — default was 300s, well past nginx's 60s cutoff
  • Extracted TTYD_PING_INTERVAL and NGINX_PROXY_TIMEOUT constants in session-manager.py for consistency
Original prompt

do you have any idea why the web terminal kills the copilot cli session after it starts doing something? it terminates "copilot" amd gets back to the zsh entry point. I can see the previous commands there


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits March 24, 2026 04:15
- session-picker.py: Wrap [c], [r], c<N> copilot launches in
  'zsh -i -c "copilot ...; exec zsh"' so the tmux session survives
  when copilot exits (instead of destroying the session and bouncing
  the user back to the session picker)
- Dockerfile: Add proxy_read_timeout/proxy_send_timeout 86400s to the
  /terminal/ nginx location to prevent 60s idle WebSocket disconnects
- session-manager.py: Same nginx timeouts for per-session terminal
  configs; add --ping-interval 30 to ttyd; extract TTYD_PING_INTERVAL
  and NGINX_PROXY_TIMEOUT constants
- entrypoint.sh: Add --ping-interval 30 to main ttyd process so
  WebSocket keepalive pings are sent every 30s

Co-authored-by: TomProkop <4339668+TomProkop@users.noreply.github.com>
Agent-Logs-Url: https://github.com/NETWORG/AgentBox/sessions/dc35a7d6-5103-4a66-92eb-b97e79dec300
Copilot AI changed the title [WIP] Fix issue with web terminal terminating copilot CLI session Fix copilot CLI session termination in web terminal Mar 24, 2026
Copilot AI requested a review from TomProkop March 24, 2026 04:16
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