From eb2c02b477a108b5715c136b8d0f9fc4c468f6c1 Mon Sep 17 00:00:00 2001 From: Brian Krabach Date: Wed, 15 Apr 2026 11:03:42 -0700 Subject: [PATCH] feat: add views to DEFAULT_SETTINGS and SYNCABLE_KEYS - Add 'views': [] to DEFAULT_SETTINGS (after 'hidden_sessions') - Add 'views' to SYNCABLE_KEYS in Session behavior section (after 'hidden_sessions') - Add 4 new tests: test_views_in_default_settings, test_views_in_syncable_keys, test_views_roundtrip_through_save_and_load, test_patch_settings_syncs_views All 61 tests pass (57 existing + 4 new). --- muxplex/settings.py | 2 ++ muxplex/tests/test_settings.py | 41 ++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/muxplex/settings.py b/muxplex/settings.py index ee02a9b..20a63fd 100644 --- a/muxplex/settings.py +++ b/muxplex/settings.py @@ -22,6 +22,7 @@ DEFAULT_SETTINGS: dict = { "default_session": None, "sort_order": "manual", "hidden_sessions": [], + "views": [], "window_size_largest": False, "auto_open_created": True, "new_session_template": "tmux new-session -d -s {name}", @@ -61,6 +62,7 @@ SYNCABLE_KEYS: frozenset[str] = frozenset( # Session behavior "sort_order", "hidden_sessions", + "views", "default_session", "window_size_largest", "auto_open_created", diff --git a/muxplex/tests/test_settings.py b/muxplex/tests/test_settings.py index 856b001..c1e4908 100644 --- a/muxplex/tests/test_settings.py +++ b/muxplex/tests/test_settings.py @@ -972,3 +972,44 @@ def test_apply_synced_settings_does_not_use_time_now(): apply_synced_settings({"fontSize": 16}, old_ts) settings = load_settings() assert settings["settings_updated_at"] == old_ts # exact match, not "close to now" + + +# ============================================================ +# Views key in DEFAULT_SETTINGS and SYNCABLE_KEYS (task-3) +# ============================================================ + + +def test_views_in_default_settings(): + """DEFAULT_SETTINGS must have 'views' key initialised to [].""" + assert "views" in DEFAULT_SETTINGS, "DEFAULT_SETTINGS must include 'views'" + assert DEFAULT_SETTINGS["views"] == [], ( + f"views default must be [], got: {DEFAULT_SETTINGS['views']!r}" + ) + + +def test_views_in_syncable_keys(): + """SYNCABLE_KEYS must include 'views'.""" + assert "views" in SYNCABLE_KEYS, "SYNCABLE_KEYS must include 'views'" + + +def test_views_roundtrip_through_save_and_load(): + """views data with two views containing session arrays survives a save/load cycle.""" + views_data = [ + {"name": "Work", "sessions": ["session-a", "session-b"]}, + {"name": "Personal", "sessions": ["session-c"]}, + ] + save_settings({"views": views_data}) + result = load_settings() + assert result["views"] == views_data, ( + f"views must survive save/load roundtrip, got: {result['views']!r}" + ) + + +def test_patch_settings_syncs_views(): + """patch_settings with 'views' bumps settings_updated_at because views is in SYNCABLE_KEYS.""" + views_data = [{"name": "Dev", "sessions": ["dev-session"]}] + patch_settings({"views": views_data}) + settings = load_settings() + assert settings["settings_updated_at"] > 0, ( + "settings_updated_at must be > 0 after patching a syncable key (views)" + )