feat(tunnel-hub): group previews by Claude Code session + retain past sessions - #79
Merged
Merged
Conversation
… 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)CLAUDE_CODE_REMOTE_SESSION_ID(fallbacks:MXCLI_HUB_SESSION,CLAUDE_CODE_SESSION_ID) and sends it on registration. Override with--hub-session.Hub
Session; a new/api/sessionsgroups endpoints by session and derives theclaude.ai/codeconversation URL from the remote id, so each session links back to its conversation.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./) 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)
CLAUDE_CODE_REMOTE_SESSION_ID(cse_…), linked back toclaude.ai/code/session_….Tests
SessionLogpersist + prune + upsert-keeps-earliest;Registry.Sessionsgrouping / offline retention after reap / viewer scoping;sessionURLderivation; client session-id precedence +DetectHubMetafill.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 (aftermake grammar);gofmt/go vetclean on touched packages.cmd/mxcli/tunnelhubandcmd/mxcli/dockersuites 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