Skip to content

fix(trace): pin cctrace port, host-net awareness, stable portless URL - #549

Merged
lroolle merged 1 commit into
mainfrom
fix/trace-ui-547
Aug 10, 2026
Merged

fix(trace): pin cctrace port, host-net awareness, stable portless URL#549
lroolle merged 1 commit into
mainfrom
fix/trace-ui-547

Conversation

@lroolle

@lroolle lroolle commented Aug 10, 2026

Copy link
Copy Markdown
Member

--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 port permanently empty, so every traced reattach warned "created without the trace port" no matter what.

  • pin cctrace --port 9317 in all four traced agents (keeps existing containers' mappings valid)
  • host-networking aware: skip the -p no-op, announce loopback:9317, check NetworkMode on reattach
  • honor host PORT env as publish port; register portless cctrace alias per traced launch -> UI + /dashboard always at https://cctrace.localhost; DEVA_TRACE_PORTLESS=0 opts out
  • export DEVA_TRACE_UI_URL into the container on create and reattach (statusline trace chip contract; container-side env can't know the host port)

Verified: 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

- 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
Copilot AI lite review requested due to automatic review settings August 10, 2026 05:27

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread agents/shared_auth.sh
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 port 9317 and make trace UI plumbing host-network aware (no -p, derive URL from NetworkMode on reattach).
  • Introduce a stable “portless” URL path (e.g. https://cctrace.localhost) and propagate DEVA_TRACE_UI_URL into containers on create and reattach.
  • Document the behavior in CHANGELOG.md and DEV-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.

Comment thread agents/shared_auth.sh
Comment on lines +291 to +296
_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}}}"
}
Comment thread agents/shared_auth.sh
Comment on lines 305 to +309
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
Comment thread agents/shared_auth.sh
Comment on lines +388 to +390
# -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
Comment thread agents/kimi.sh
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}")
@lroolle
lroolle merged commit 267d2c0 into main Aug 10, 2026
5 checks passed
@lroolle
lroolle deleted the fix/trace-ui-547 branch August 10, 2026 05:39
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.

--trace UI unreachable: cctrace >=0.36 port move + HOST_NET false warning

2 participants