Commit graph

25 commits

Author SHA1 Message Date
Lawrence Chen
27fa3873be
Add claude-teams, omo, and __tmux-compat to Go relay CLI for SSH sessions (#2238)
* Add claude-teams, omo, and __tmux-compat to Go relay CLI

These commands previously only existed in the Swift CLI which uses Unix
domain sockets and can't connect over TCP relay. The Go relay CLI already
handles TCP connections, so adding the commands here makes them work
inside `cmux ssh` sessions.

- `cmux claude-teams`: creates tmux shim scripts, configures environment
  (fake TMUX/TMUX_PANE, socket path, workspace/surface IDs), and execs
  into `claude --teammate-mode auto`
- `cmux omo`: same pattern for OpenCode with terminal-notifier shim
- `cmux __tmux-compat`: translates tmux commands (split-window,
  send-keys, capture-pane, display-message, list-panes, etc.) into cmux
  JSON-RPC calls over the relay socket. Includes main-vertical layout
  tracking, wait-for signaling, and format string rendering.

* Fix: search original PATH before environment modification

findExecutable was called after configureAgentEnvironment prepended the
shim directory to PATH. The Swift CLI searches the original PATH before
modification. Renamed to findExecutableInPath with explicit PATH arg and
moved the search before configureAgentEnvironment.

* Fix cmux omo hang and port oh-my-opencode plugin setup

Root cause: socketRoundTripV2 had no read timeout. When connecting to a
stale relay port (accepted TCP but never responded), the read blocked
forever. This caused getFocusedContext to hang, blocking agent launch.

Fixes:
- Add 15s read deadline to socketRoundTripV2 (affects all v2 RPC calls)
- Add 5s timeout to getFocusedContext so agent launch proceeds even if
  system.identify is slow
- Port omoEnsurePlugin from Swift: creates shadow config dir, adds
  oh-my-opencode to plugin list, symlinks node_modules/package.json,
  installs plugin via bun/npm if missing, configures tmux settings
  (enabled=true, lower min widths), sets OPENCODE_CONFIG_DIR

* Fix: use bun as runtime for node-script opencode when node is missing

opencode is installed via bun as a #!/usr/bin/env node script, but on
some systems (like the macmini) bun is installed without a standalone
node binary. Detect node scripts and fall back to bun as the runtime
since bun is node-compatible.

* Fix subagent pane theme: preserve COLORTERM, keep TERM_PROGRAM

The cmux ssh bootstrap exports COLORTERM=truecolor and TERM_PROGRAM=ghostty.
Our configureAgentEnvironment was unsetting TERM_PROGRAM and not setting
COLORTERM, causing subagent panes (created via split-window) to lose
truecolor detection and render with wrong theme colors.

* Restore TERM_PROGRAM unset, keep COLORTERM=truecolor

* Force dark colorScheme in opencode shadow config for SSH

* Remove hardcoded dark colorScheme, let opencode detect naturally

* Detect system color scheme for opencode over SSH

* Remove color scheme detection workaround, let opencode handle natively

---------

Co-authored-by: Lawrence Chen <lawrencecchen@users.noreply.github.com>
2026-03-27 21:04:24 -07:00
Lawrence Chen
dfcbaa3220
Fix SSH remote CLI and loopback proxy follow-ups 2026-03-17 01:58:50 -07:00
Lawrence Chen
96bd2463b8
Add regression tests for SSH remote CLI follow-ups 2026-03-17 01:53:23 -07:00
Lawrence Chen
bbdb626ef3
Fix nightly remote daemon and SSH relay wiring 2026-03-17 00:59:52 -07:00
Lawrence Chen
8cd36775f0
Add remote CLI relay regressions 2026-03-17 00:59:45 -07:00
Lawrence Chen
60aab29e39
Make remote proxy close idempotent 2026-03-17 00:00:40 -07:00
Lawrence Chen
832426af56
Stabilize SSH remote flow after merging main 2026-03-16 23:57:48 -07:00
Lawrence Chen
b0bfabdb6a Optimize remote daemon builds and TCP latency 2026-03-13 04:34:58 -07:00
Lawrence Chen
2e6856ff2f Fix ssh stack review regressions 2026-03-13 04:14:52 -07:00
Lawrence Chen
19b59cae37 Reapply "Merge pull request #239 from manaflow-ai/issue-151-ssh-remote-port-proxying"
This reverts commit f7cbbad434.
2026-03-12 15:54:26 -07:00
Lawrence Chen
f7cbbad434 Revert "Merge pull request #239 from manaflow-ai/issue-151-ssh-remote-port-proxying"
This reverts commit 78e4bd32ba, reversing
changes made to cf75da8f8a.
2026-03-12 14:45:58 -07:00
Lawrence Chen
a75faa82f1 Fix SSH review regressions 2026-03-12 05:24:12 -07:00
Lawrence Chen
8a9e28e129 Secure remote daemon distribution and relay auth 2026-03-12 05:04:44 -07:00
Lawrence Chen
76cfe01fa2 Add remote daemon distribution regressions 2026-03-12 05:04:35 -07:00
Lawrence Chen
30bb74dc92 Merge branch 'pr-374-ssh-remote-cli-relay' into issue-151-ssh-remote-port-proxying
# Conflicts:
#	CLI/cmux.swift
#	Sources/ContentView.swift
#	Sources/GhosttyTerminalView.swift
#	Sources/Panels/TerminalPanel.swift
#	Sources/SocketControlSettings.swift
#	Sources/TabManager.swift
#	Sources/TerminalController.swift
#	Sources/Workspace.swift
#	daemon/remote/README.md
#	daemon/remote/cmd/cmuxd-remote/main.go
#	docs/remote-daemon-spec.md
#	tests_v2/test_ssh_remote_cli_metadata.py
2026-03-09 18:31:10 -07:00
Lawrence Chen
bfe36f817d Address remaining PR #239 review findings 2026-02-28 19:14:46 -08:00
Lawrence Chen
47f4b5e55a Address PR review feedback for SSH remote workspace flow 2026-02-28 17:36:07 -08:00
Lawrence Chen
6800cd44bb WIP: advance ssh remote workspace proxying 2026-02-28 17:05:55 -08:00
Lawrence Chen
daa340fa87 Harden cmux ssh for mixed-version remote sessions 2026-02-24 22:09:27 -08:00
Lawrence Chen
257afc0623 Fix SSH relay/socket regressions and restore session/focus contracts 2026-02-24 21:20:24 -08:00
Raghav Pillai
946269455d Add CLI relay and docs for remote daemon
- Add CLI relay (cli subcommand and cmux symlink) to cmuxd-remote
- Implement socket discovery and TCP retry logic for relay connections
- Document CLI relay behavior, bootstrap symlink, and reverse TCP forwarding in README
- Update remote daemon spec with CLI relay details, status matrix, and PR reference
- Note bootstrap creates ~/.cmux/bin/cmux symlink and writes ~/.cmux/socket_addr
- Clarify integration steps and relay process behavior (ssh -N -R, ControlPath/ExitOnForwardFailure)
2026-02-23 18:42:44 +02:00
Raghav Pillai
1a1caca99d Add cmux CLI relay and tests
- Introduce CLI client (cmux) to relay v1 text and v2 JSON-RPC commands over Unix/TCP sockets
- Implement command specs, flag parsing, v1/v2 round-trips, TCP retry with address refresh
- Add browser subcommand mapping and rpc passthrough support
- Support busybox-style invocation when argv[0]=="cmux" and add 'cli' subcommand
- Add comprehensive unit tests for socket dialing, CLI commands, flag-to-param mapping, and env defaults
- Add socket_addr file fallback reader and random request id generation
2026-02-23 18:24:14 +02:00
Lawrence Chen
a40a972424 test: harden remote daemon bootstrap and failure coverage 2026-02-20 23:52:48 -08:00
Lawrence Chen
89fa361500 feat: bootstrap remote daemon over ssh for remote workspaces 2026-02-20 23:44:06 -08:00
Lawrence Chen
aaf2ef4c3a feat: add ssh reuse defaults and remote daemon scaffold 2026-02-20 23:32:48 -08:00