feat: update state path to muxplex, add MUXPLEX_STATE_DIR env var, add active_view field

- Change _default_state_dir from 'tmux-web' to 'muxplex'
- Update STATE_DIR to prefer MUXPLEX_STATE_DIR env var with TMUX_WEB_STATE_DIR fallback
- Add 'active_view': 'all' to empty_state() between active_remote_id and session_order
- Update module docstring schema to document active_view field
- Add tests: test_empty_state_has_active_view_key, test_empty_state_active_view_defaults_to_all, test_state_dir_uses_muxplex_name
This commit is contained in:
Brian Krabach
2026-04-15 10:59:57 -07:00
parent 59b1672275
commit d9e9ab2fb6
2 changed files with 27 additions and 2 deletions
+9 -2
View File
@@ -5,6 +5,8 @@ State schema (all values are plain JSON-serialisable dicts):
{
"active_session": str | None,
"active_remote_id": str | None,
"active_view": str, # 'all' | 'hidden' | view name
"session_order": list[str],
"sessions": {
"<name>": {
@@ -37,8 +39,12 @@ from pathlib import Path
# Paths
# ---------------------------------------------------------------------------
_default_state_dir = Path.home() / ".local" / "share" / "tmux-web"
STATE_DIR: Path = Path(os.environ.get("TMUX_WEB_STATE_DIR", _default_state_dir))
_default_state_dir = Path.home() / ".local" / "share" / "muxplex"
STATE_DIR: Path = Path(
os.environ.get(
"MUXPLEX_STATE_DIR", os.environ.get("TMUX_WEB_STATE_DIR", _default_state_dir)
)
)
STATE_PATH: Path = STATE_DIR / "state.json"
# ---------------------------------------------------------------------------
@@ -60,6 +66,7 @@ def empty_state() -> dict:
return {
"active_session": None,
"active_remote_id": None,
"active_view": "all",
"session_order": [],
"sessions": {},
"devices": {},
+18
View File
@@ -92,6 +92,24 @@ def test_empty_state_returns_independent_dicts():
assert s2["devices"] == {}
def test_empty_state_has_active_view_key():
state = empty_state()
assert "active_view" in state
def test_empty_state_active_view_defaults_to_all():
state = empty_state()
assert state["active_view"] == "all"
def test_state_dir_uses_muxplex_name():
import muxplex.state as state_mod
path_str = str(state_mod._default_state_dir)
assert "muxplex" in path_str
assert "tmux-web" not in path_str
# ---------------------------------------------------------------------------
# empty_bell()
# ---------------------------------------------------------------------------