Repository navigation
Description
Client or integration
Codex App
Area
Service lifecycle
Summary
On a default-bind install (config.hostname unset), the desktop's approved takeover never succeeds. Approving the "A runtime is already listening. Take it over?" prompt ends in:
state: taking-over
reason: the guarded stop could not confirm the approved runtime:
The approved runtime or managing CLI changed: the tracked runtime record changed; no stop was attempted.
runtime process: still running or never started
The old runtime is never signalled, so the desktop waits ~165 s and the port stays occupied. Retrying cannot help: nothing rewrites the record while the old runtime keeps serving.
The cause is two readers of the same runtime-port.json disagreeing about an absent optional field. hostname is optional in the record schema, and a default bind has no configured value to persist, so the writer drops the key. Liveness discovery then defaults it to loopback for its verdict, while the guarded stop defaults it to "" for comparison — so the guard compares "" against "127.0.0.1" and always reports drift.
Reproduction
Environment: Desktop 2.97.0 (notarized), CLI on PATH 2.97.0, the runtime it wanted to stop was 2.96.0 started by the launchd service com.opencodex.proxy, config home ~/.opencodex, port 10100 (default), config.hostname unset.
- Install the CLI and start the proxy through the service on a default bind:
ocx service install && ocx service start - Confirm the record has no
hostnamekey:cat ~/.opencodex/runtime-port.json # {"pid":32333,"port":10100,"attestationSecret":"..."} <- no hostname
- Launch the desktop app while that runtime is still running, and approve the takeover prompt.
Expected: the approved runtime is stopped and the desktop starts its own.
Actual: approval-changed / the tracked runtime record changed, runtime still running, and the record's mtime never changes.
Root cause, with hostname optional in the record (src/config/process-state.ts:37, and isValidRuntimePortState accepts undefined):
- The writer drops it when nothing is configured:
src/cli/index.ts:609writeshostname: bound.config.hostname, which isundefinedfor a default bind, soJSON.stringifyomits the key. src/server/proxy-liveness.ts:525reads absence as loopback (opts.hostname?.trim() || "127.0.0.1"), soocx resolve --jsonreportsliveness.hostname: "127.0.0.1"for that record.src/config/tracked-runtime-inspection.ts:150reads absence as""(hostname: parsed.hostname ?? "").- The desktop forwards the discovered value as the approved expectation (
desktop/src-tauri/src/runtime_stop.rs:254,--expect-hostname), andsrc/cli/stop-approval.ts:147-149compares the two directly: pid and port match,"" !== "127.0.0.1", so it returnsapprovalChanged("the tracked runtime record changed").
Observed ocx resolve --json in the failing state (abridged):
{"liveness":{"status":"live","pid":32333,"port":10100,"source":"runtime","hostname":"127.0.0.1","version":"2.96.0"},
"takeover":{"kind":"supported","protocolVersion":1,"minimumCliVersion":"2.61.0","token":"..."}}Proposed fix: treat an absent record hostname as unknown rather than an empty host, compare bind scope through probeHostname only when the record carries one, and persist the scope the listener actually bound. Patch with regression tests: #8182.
Version
Desktop 2.97.0; the running proxy it refused to stop was 2.96.0.
Operating system
macOS 27.2 (26B123), arm64 (Apple M4 Max)
Provider and model
No response
Logs or error output
$ cat ~/.opencodex/runtime-port.json
{"pid":32333,"port":10100,"attestationSecret":"..."}
$ ocx resolve --json | jq '.liveness'
{"status":"live","pid":32333,"port":10100,"source":"runtime","hostname":"127.0.0.1","version":"2.96.0"}
# desktop, after approving the takeover
state: taking-over
reason: the guarded stop could not confirm the approved runtime: The approved runtime or managing CLI changed: the tracked runtime record changed; no stop was attempted.
runtime process: still running or never startedWorkaround that avoids the takeover entirely: quit the desktop, ocx service stop, ocx service uninstall, reopen the app so it supervises its own runtime, then ocx restore back to re-point Codex at that proxy.
Not a duplicate of #7771: there the Windows Task Scheduler registration survives and the port is never freed. Here no manager stop is ever attempted — the guard refuses first, on a valid record that simply omits an optional field.
Screenshots and supporting files
No response
Redacted configuration
No response
Checks
- I searched existing issues and documentation.
- I removed secrets, tokens, account details, request credentials, and personal data.
Activity
github-actions commentedon Nov 5, 2026
Automated translation bookkeeping — detected language: English.
github-actions commentedon Nov 5, 2026
Issue reopened
The report now contains the information required by the automated check. Thanks for updating it.
[-][Bug][macOS] desktop takeover always fails on a default-bind install: tracked-runtime-inspection reads an absent record hostname as "" while resolve reports 127.0.0.1[/-][+][Bug]: desktop takeover always fails on a default-bind install: tracked-runtime-inspection reads an absent record hostname as "" while resolve reports 127.0.0.1[/+]fix(stop): read an absent tracked-record hostname as unknown
fix(cli): preserve default bind identity for guarded stops (#8221)
lidge-jun commentedon Nov 6, 2026
Fixed on dev by #8221 (250ef01): an absent tracked-record hostname is no longer treated as loopback. It ships in the next release from dev.
feat(upstream): adopt 37 post-v2.97.0 fixes, triage 5 issues, close l…