Skip to content

feat(terminal): host Claude PTY terminal behind a flag - #414

Merged
jrothrock merged 1 commit into
mainfrom
feat/host-claude-terminal
Sep 24, 2026
Merged

jrothrock merged 1 commit into
mainfrom
feat/host-claude-terminal

Conversation

@jrothrock

Copy link
Copy Markdown
Collaborator

What

Adds handleClaudeHostWS — a browser terminal bridged to an interactive claude TUI running on the host in the project's workspace directory. It mirrors handleHostWS (persistent per-project tmux session on the isolated host socket, created on first open and reattached thereafter) but the session's pane runs the real claude TUI instead of a shell.

This is branch 1 of 4 in replacing the bespoke ChatDock host chat with a real terminal. With a real PTY, slash commands, /login, permission prompts, plan mode, and the status line all work natively — no chat rendering to keep at parity (and the 401 OAuth revoked → /login flow Just Works).

Details

  • Route: /p/{id}/claude/ws
  • Session name: distinct -claude suffix so window sizing/pane stay independent of the dev + host-shell sessions
  • Reuses bridgePTY byte pump, resize hook, and resolveClaudeBin unchanged
  • Gated behind CORRAL_HOST_CLAUDE_TERMINAL=1 while brought up alongside the existing chat; flag removed once it replaces the chat UI (branch 4)

Security

NOT sandboxed — same trust terms as the existing host shell (handleHostWS): dashboard is loopback-only + token-gated, WebSocket is same-origin only (terminalUpgrader.CheckOrigin). The claude permission gate (interactive prompts here) remains the real guardrail. A loudened trust banner lands with the frontend branch.

Follow-ups (later branches)

  • handleTerminalAction split/clear right-click wiring for the new terminal (frontend branch); the "claude" kind name currently overloads the container dev session
  • Parent-conversation linkage moves to sessionId-based mapping (branch 2)
  • Global (non-project) host-claude terminal (later)

Test

terminal_claude_test.go — session-name distinctness/stability + flag gate. go build, go vet, tests green.

🤖 Generated with Claude Code

Add handleClaudeHostWS: a browser terminal bridged to an interactive
`claude` TUI running on the host in the project's workspace, mirroring
handleHostWS's persistent per-project tmux session (isolated host socket,
create-on-first-open, reattach thereafter) but with `claude` as the
session's pane command instead of a shell. This gives slash commands,
/login, permission prompts, plan mode and the status line natively — the
groundwork for replacing the bespoke ChatDock host chat with a real
terminal.

Gated behind CORRAL_HOST_CLAUDE_TERMINAL=1 while it's brought up
alongside the existing chat; the flag is removed once it replaces the
chat UI. Route: /p/{id}/claude/ws. Session name is a distinct "-claude"
suffix so its sizing/pane stay independent of the dev + host-shell
sessions.

Reuses the existing bridgePTY byte pump, resize hook, and
resolveClaudeBin locator unchanged. NOT sandboxed (same trust terms as
the host shell: loopback-only, token-gated, same-origin WS).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jrothrock
jrothrock merged commit 4009129 into main Sep 24, 2026
1 check passed
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