Skip to content

feat(tunnel-hub): group previews by Claude Code session + retain past sessions - #79

Merged
ako merged 1 commit into
mainfrom
claude/mxbuild-diagnostics-spike-emta6h
Aug 1, 2026
Merged

feat(tunnel-hub): group previews by Claude Code session + retain past sessions#79
ako merged 1 commit into
mainfrom
claude/mxbuild-diagnostics-spike-emta6h

Conversation

@ako

@ako ako commented Aug 1, 2026

Copy link
Copy Markdown
Owner

The hub overview was a flat list of live endpoints that vanished ~10 min after a container went idle. This groups endpoints by the Claude Code session that exposed them, and retains past sessions so you can see older ones.

What changed

Client (mxcli run --hub)

  • Auto-detects the session id from CLAUDE_CODE_REMOTE_SESSION_ID (fallbacks: MXCLI_HUB_SESSION, CLAUDE_CODE_SESSION_ID) and sends it on registration. Override with --hub-session.

Hub

  • Backends carry a Session; a new /api/sessions groups endpoints by session and derives the claude.ai/code conversation URL from the remote id, so each session links back to its conversation.
  • A durable SessionLog (cmd/mxcli/tunnelhub/sessions.go) records every endpoint a session exposed. On reap/deregister the live entry is stamped into it, so the overview keeps offline sessions (state: available → stale → offline). Persisted to --sessions-file (default ~/.mxcli/hub-sessions.json, survives restarts), pruned after --session-retention (default 30 days). Atomic 0600 writes, mirroring the existing key store.
  • The overview page (/) is regrouped into per-session cards — each links to its claude.ai conversation and lists its endpoints. Viewer-scoped exactly like /api/backends (auth-on filters to the owner).

Design decisions (confirmed with the requester)

  • Retention: persist to disk, 30-day window (survives hub restarts, bounded).
  • Grouping key: CLAUDE_CODE_REMOTE_SESSION_ID (cse_…), linked back to claude.ai/code/session_….

Tests

SessionLog persist + prune + upsert-keeps-earliest; Registry.Sessions grouping / offline retention after reap / viewer scoping; sessionURL derivation; client session-id precedence + DetectHubMeta fill.

Backward compatible: an older client that sends no session id groups under "(no session)"; open (no-auth) hubs behave as before but now with grouping + history.

Validation

  • go build ./... clean (after make grammar); gofmt/go vet clean on touched packages.
  • cmd/mxcli/tunnelhub and cmd/mxcli/docker suites pass.

Note: the hub (hub.mxcli.org) must be redeployed from this branch to pick up the change; existing clients start sending the session id automatically once upgraded.

🤖 Generated with Claude Code

https://claude.ai/code/session_01JXnEgoc2NQP1Y2TWMCMXC4


Generated by Claude Code

… sessions

The overview was a flat list of live endpoints that vanished ~10 min after a
container went idle. Group them by the Claude Code session that exposed them, and
keep past sessions visible.

Client (`mxcli run --hub`):
- Auto-detects the session id from CLAUDE_CODE_REMOTE_SESSION_ID (fallbacks:
  MXCLI_HUB_SESSION, CLAUDE_CODE_SESSION_ID) and sends it on registration.
  Override with `--hub-session`.

Hub:
- Backends carry a Session; a new /api/sessions groups endpoints by session,
  deriving the claude.ai/code conversation URL from the remote id so each session
  links back.
- A durable SessionLog (cmd/mxcli/tunnelhub/sessions.go) records every endpoint a
  session exposed. On reap/deregister the live entry is stamped into it, so the
  overview keeps offline sessions (state: available → stale → offline). Persisted
  to `--sessions-file` (default ~/.mxcli/hub-sessions.json, survives restarts),
  pruned after `--session-retention` (default 30d). Atomic 0600 writes, mirroring
  the key store.
- Overview page (`/`) regrouped into per-session cards, each linking to its
  claude.ai conversation and listing its endpoints; viewer-scoped like
  /api/backends.

Tests: SessionLog persist+prune+upsert, Registry.Sessions grouping/offline
retention/viewer scoping, sessionURL derivation, client session-id precedence.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JXnEgoc2NQP1Y2TWMCMXC4
@ako
ako merged commit e0cad96 into main Aug 1, 2026
5 checks passed
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.

2 participants