fix(trace): pin cctrace port, host-net awareness, stable portless URL - #549
Conversation
- cctrace >= 0.36 binds 8722 by default while deva publishes 9317; pin --port 9317 in all four traced agent commands - HOST_NET=true made docker port permanently empty: skip the publish, announce the loopback URL, check NetworkMode on reattach instead of warning falsely on every attach - honor host PORT env as the publish port (portless-style wrappers) - register/refresh portless `cctrace` alias per traced launch: UI and /dashboard at a stable https://cctrace.localhost route; DEVA_TRACE_PORTLESS=0 opts out, DEVA_TRACE_URL overrides - export DEVA_TRACE_UI_URL into the container on create and reattach (statusline trace chip contract) Closes #547
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 64b2f113f8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| local port="$1" | ||
| [ "${DEVA_TRACE_PORTLESS:-1}" = "1" ] || return 1 | ||
| command -v portless >/dev/null 2>&1 || return 1 | ||
| portless alias cctrace "$port" >/dev/null 2>&1 || return 1 |
There was a problem hiding this comment.
Skip portless registration during dry runs
When portless is installed, deva <agent> --trace --dry-run still reaches this call before the dry-run exit and mutates the global cctrace alias. If an existing traced session currently owns that alias, the dry run can redirect https://cctrace.localhost to the newly probed port even though no container is started there, breaking the live session's stable URL. Guard this registration when DRY_RUN=true while still computing a display-only URL.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Pull request overview
Fixes --trace UI reachability regressions introduced by newer cctrace defaults and improves trace UX under host networking by stabilizing port selection and announcing a consistent, host-reachable UI URL (including optional portless routing) across traced agents.
Changes:
- Pin traced agent launches to
cctrace’s container-side port9317and make trace UI plumbing host-network aware (no-p, derive URL fromNetworkModeon reattach). - Introduce a stable “portless” URL path (e.g.
https://cctrace.localhost) and propagateDEVA_TRACE_UI_URLinto containers on create and reattach. - Document the behavior in
CHANGELOG.mdandDEV-LOGS.md.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| deva.sh | Ensures DEVA_TRACE_UI_URL is refreshed on attach and passed into docker exec when tracing. |
| agents/shared_auth.sh | Implements host-net detection, optional portless URL resolution, publish-port selection, and safer trace UI announcing/opening behavior. |
| agents/claude.sh | Pins traced cctrace invocation to port 9317. |
| agents/codex.sh | Pins traced cctrace invocation to port 9317 for codex profile. |
| agents/grok.sh | Pins traced cctrace invocation to port 9317 for grok profile. |
| agents/kimi.sh | Pins traced cctrace invocation to port 9317 for kimi profile. |
| CHANGELOG.md | Documents stable trace URL + host-net fixes and the new DEVA_TRACE_UI_URL contract. |
| DEV-LOGS.md | Adds a dev log entry describing the trace fixes and portless behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| _trace_resolve_ui_url() { | ||
| local port="$1" | ||
| local routed="" | ||
| routed=$(_trace_portless_url "$port") || routed="" | ||
| printf '%s' "${DEVA_TRACE_URL:-${routed:-http://127.0.0.1:${port}}}" | ||
| } |
| local free_port="" | ||
| while [ "$tries" -lt 12 ]; do | ||
| if ! (exec 3<>"/dev/tcp/127.0.0.1/$port") 2>/dev/null; then | ||
| free_port="$port" | ||
| break | ||
| fi | ||
| port=$((port + 1)) | ||
| tries=$((tries + 1)) | ||
| done | ||
| if [ -n "${PORT:-}" ] && [[ "${PORT}" =~ ^[0-9]{2,5}$ ]]; then | ||
| free_port="$PORT" | ||
| else | ||
| local port=9317 |
| # -k: portless https routes use a local CA curl may not trust; | ||
| # this is a loopback readiness probe, not a trust decision. | ||
| if curl -skf -o /dev/null --max-time 1 "$url/" 2>/dev/null; then |
| DEVA_TRACE_ACTIVE=true | ||
| setup_trace_ui_port | ||
| AGENT_COMMAND=("cctrace" "kimi" "--no-open" "--" "${AGENT_COMMAND[@]:1}") | ||
| AGENT_COMMAND=("cctrace" "kimi" "--no-open" "--port" "9317" "--" "${AGENT_COMMAND[@]:1}") |
--trace has been silently broken since the cctrace 0.38.1 pin: cctrace >= 0.36 binds 8722, deva publishes 9317, the poll-then-open never connects. Separately HOST_NET=true makes
docker portpermanently empty, so every traced reattach warned "created without the trace port" no matter what.cctrace --port 9317in all four traced agents (keeps existing containers' mappings valid)cctracealias per traced launch -> UI + /dashboard always at https://cctrace.localhost; DEVA_TRACE_PORTLESS=0 opts outVerified: dry-run carries --port 9317; host-net dry-run publishes nothing and exports the URL; portless route serves the live dashboard 200 end-to-end.
Closes #547
🤖 Generated with Claude Code