Add mox recent and rework mox list into a single enriched table#2
Merged
Conversation
Add a SessionDetail type and a ListSessionsDetailed() method that fetches window count, attached state, and last-activity time in a single list-sessions call, plus a pure parseSessionDetails helper. Extends the Tmux interface and the test fake.
New internal/history package persists a small log of created/attached sessions to $XDG_STATE_HOME/mox/recent.json (deduped by name, capped, newest-first). Every operation is best-effort: missing, unwritable, or corrupt history is treated as empty and never surfaces a blocking error.
List now joins ListSessionsDetailed output with the config so SessionInfo carries window count, attached state, last activity, and a config-derived host summary (new Session.HostSummary helper). CreateOrAttach and CreateAdHoc record created/attached events through an injected recorder (history.Record in production, a no-op default in tests).
Rewrite mox list as one aligned, ANSI-aware table (origin, state, attached, window count, relative activity, host summary) with a Recent: footer, replacing the fixed-width Configured/Unmanaged sections. Add the mox recent command (alias r, -n/--limit) backed by the history store, showing each recorded session's current running/gone state. Includes a shared relative-time helper and column renderer; updates README and CHANGELOG.
Use slices.Concat instead of cross-slice append in renderList, and create the state directory 0o700 — it holds session names.
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.
mox list
One aligned, ANSI-aware table replacing the fixed-width Configured/Unmanaged sections: origin (mox/tmux), state (+attached), window count, relative last-activity, and a config-derived host summary per session. Degrades cleanly under NO_COLOR and non-TTY.
mox recent (alias: r)
New command showing the sessions you most recently created or attached to, newest first, with each one's current running/gone state. Backed by a small best-effort history file at $XDG_STATE_HOME/mox/recent.json — missing/corrupt/unwritable history never breaks a real operation. This is the only state mox persists; README's honest-defaults bullet updated accordingly.
Plumbing
Tests across all four layers; lint-clean under golangci-lint v2.