Allow SSH and Remote Control clients to share the same app-server
Summary
An SSH-managed Codex connection and account-based Remote Control should be able to control the same host and share one app-server, but the current lifecycle management makes the two workflows mutually exclusive for one user/CODEX_HOME.
Real-world topology
- A company MacBook Pro can reach a Coder development host over SSH.
- A home MacBook Air cannot reach the private SSH network and must use account-based Remote Control.
- Both Macs need to control the same Coder host, tasks, approvals, configuration, and thread history.
Observed behavior
The Codex App SSH workflow starts:
codex -c features.code_mode_host=true app-server --listen unix://
Attempting to enable Remote Control on the same Coder host with:
codex remote-control start
fails with:
app server is running but is not managed by codex app-server daemon
codex remote-control pair --json then times out. Stopping the SSH-managed app-server would interrupt active tasks, so users are forced to choose one control path.
Expected behavior
A single app-server should support both:
- SSH/local Unix-socket clients
- Secure Remote Control relay clients
Both transports should share tasks, approvals, configuration, and the same session database.
Alternatively, codex remote-control start should safely attach to or upgrade an existing SSH-managed app-server without interrupting active turns.
Why current workarounds are insufficient
- Separate
CODEX_HOMEinstances split task history, authentication, and configuration. - Routing the home Mac through the company Mac requires the company Mac and its desktop App to remain online.
- Replacing Codex App SSH access with Remote Control everywhere removes a useful direct connection path that is available on the corporate network.
- Ordinary SSH can coexist, but that does not provide the Codex App's SSH project workflow.
Environment
- Codex/ChatGPT desktop app:
26.715.21425 - Local bundled CLI:
0.145.0-alpha.18 - Coder CLI:
0.144.5
Feedback reference
Codex feedback thread ID: 019f6e74-ee12-7ef2-85b9-0a887c31663d
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
- #33556
Powered by Codex Action
Confirmed workaround: modify the Codex wrapper at /root/.local/bin/codex so Codex Desktop starts the SSH App Server with Remote Control enabled while continuing to use the same history directory.
Add the following logic before executing the real Codex binary:
export CODEX_HOME="/root/.codex"
unset CODEX_SQLITE_HOME
case " $* " in
*" --remote-control "*) ;;
*" app-server "*" --listen unix://"*)
set -- "$@" --remote-control
;;
esac
exec /path/to/real/codex "$@"
Make sure /root/.local/bin appears before the NVM Codex path in PATH. After restarting the App Server and running codex remote-control pair, both Codex Desktop and the mobile app can control the same Codex Server and share the same conversation history.
I can confirm the app-server ownership conflict on a newer Linux setup.
Environment: Ubuntu 22.04.5 LTS; Codex Desktop 26.917.62051; remote npm-installed Codex CLI 0.156.1 (Node.js 24.18.0).
After disconnecting and reconnecting the Desktop SSH connection, the remote host launched codex -c features.code_mode_host=true app-server --listen unix:// again. The replacement process started in an SSH session scope at 17:26:08; loginctl reported Remote=yes, Service=sshd, and later State=closing, while the app-server remained alive and owned the default control socket.
codex app-server daemon version reported status: "running" with both cliVersion and appServerVersion at 0.156.1, but managedCodexVersion: null. Its reported managed executable under ~/.codex/packages/app-server-daemon/current/bin/codex did not exist. In this setup, daemon restart refused the reachable server with app server is running but is not managed by codex app-server daemon.
This exposes a useful distinction for the CLI: socket reachable versus lifecycle managed. Could Desktop SSH attach to an existing managed daemon, or launch through the manager when appropriate? If SSH must own a separate server, a distinct socket namespace would avoid this collision. For migration, an explicit safe takeover flow, or an error showing the socket owner's PID, command, and SSH session, would be more actionable than only "not managed". A regression test covering SSH reconnect followed by daemon start/restart would also help.
Related: #24542. I have not tested immediate proxy respawn after terminating the server or Remote Control pairing on this host.
I reproduced the same lifecycle-management failure on Linux AArch64 with Codex CLI 0.158.0.
Environment
- Raspberry Pi 4 Model B Rev 1.5
- Ubuntu 24.04.5 LTS
- Kernel 6.8.0-1065-raspi
- AArch64
- Codex CLI: 0.158.0
- Running app-server: 0.158.0
- Codex Desktop SSH connection
Desktop SSH had started an unmanaged server:
<HOME>/.codex/packages/standalone/releases/0.158.0-aarch64-unknown-linux-musl/bin/codex \
-c features.code_mode_host=true app-server --listen unix://
The daemon package directory still contained the older 0.157.1 release, but packages/app-server-daemon/current was missing. The standalone installation had a complete 0.158.0 package.
daemon version reported a reachable, version-matched server, but no selected managed package:
{
"status": "running",
"managedCodexVersion": null,
"cliVersion": "0.158.0",
"appServerVersion": "0.158.0"
}
The apparent recovery commands formed a dead end:
$ codex app-server daemon update --from-cli -y
Error: no daemon package is selected; run `codex app-server daemon start` first
$ codex app-server daemon start
{"status":"alreadyRunning", ... "managedCodexVersion":null, ...}
$ codex app-server daemon restart
Error: app server is running but is not managed by codex app-server daemon
Recovery required manually restoring the daemon package selection and performing a controlled takeover:
- Validate and copy the complete standalone 0.158.0 package into
packages/app-server-daemon/releases/. - Create
packages/app-server-daemon/currentpointing to that release. - Verify and terminate only the unmanaged SSH app-server process.
- Immediately run
codex app-server daemon start. - Run
codex app-server daemon update --from-cli -y.
Afterwards, daemon restart succeeded repeatedly and the running process used:
<HOME>/.codex/packages/app-server-daemon/releases/<LOCAL_RELEASE_ID>/bin/codex \
app-server --listen unix:// --managed-daemon
Final state:
{
"status": "running",
"backend": "pid",
"managedCodexVersion": "0.158.0",
"cliVersion": "0.158.0",
"appServerVersion": "0.158.0"
}
The daemon PID record matched the live process and its executable was inside the daemon releases directory.
This suggests that daemon start needs a safe adoption/takeover path when the socket is owned by a Desktop SSH app-server and the daemon package selection is missing. At minimum, it should not return only alreadyRunning after daemon update has instructed the user to run daemon start; it should explain how to restore the missing selection safely.