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:
+9
-2
@@ -5,6 +5,8 @@ State schema (all values are plain JSON-serialisable dicts):
|
|||||||
|
|
||||||
{
|
{
|
||||||
"active_session": str | None,
|
"active_session": str | None,
|
||||||
|
"active_remote_id": str | None,
|
||||||
|
"active_view": str, # 'all' | 'hidden' | view name
|
||||||
"session_order": list[str],
|
"session_order": list[str],
|
||||||
"sessions": {
|
"sessions": {
|
||||||
"<name>": {
|
"<name>": {
|
||||||
@@ -37,8 +39,12 @@ from pathlib import Path
|
|||||||
# Paths
|
# Paths
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
_default_state_dir = Path.home() / ".local" / "share" / "tmux-web"
|
_default_state_dir = Path.home() / ".local" / "share" / "muxplex"
|
||||||
STATE_DIR: Path = Path(os.environ.get("TMUX_WEB_STATE_DIR", _default_state_dir))
|
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"
|
STATE_PATH: Path = STATE_DIR / "state.json"
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
@@ -60,6 +66,7 @@ def empty_state() -> dict:
|
|||||||
return {
|
return {
|
||||||
"active_session": None,
|
"active_session": None,
|
||||||
"active_remote_id": None,
|
"active_remote_id": None,
|
||||||
|
"active_view": "all",
|
||||||
"session_order": [],
|
"session_order": [],
|
||||||
"sessions": {},
|
"sessions": {},
|
||||||
"devices": {},
|
"devices": {},
|
||||||
|
|||||||
@@ -92,6 +92,24 @@ def test_empty_state_returns_independent_dicts():
|
|||||||
assert s2["devices"] == {}
|
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()
|
# empty_bell()
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user