Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,20 @@ def test_switching_categories_retains_dirty_settings(tmp_path, monkeypatch):
app._update_dirty_setting("theme", "light")
app.selected_category = "Data"
assert "theme" in app.dirty_settings
assert app.dirty_settings["theme"] == "light"
assert app.dirty_settings["theme"] == "light"


def test_dirty_settings_seeded_from_loaded_settings(tmp_path, monkeypatch):
# Regression: __init__ used to overwrite `dirty_settings` with an empty
# dict immediately after seeding it from `self.settings`, which silently
# discarded any persisted values before the UI rendered.
monkeypatch.setattr(Path, "home", lambda: tmp_path)
app = SettingsApp()
assert app.dirty_settings == app.settings
assert app.dirty_settings == {
"theme": "dark",
"prompt_symbol": "➜",
"show_git_status": True,
"auto_complete": True,
"csv_max_rows": 50,
}
3 changes: 1 addition & 2 deletions trushell/commands/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,9 @@ def __init__(self, **kwargs) -> None:
super().__init__(**kwargs)
self.manager = SettingsManager()
self.settings = self.manager.load()
# Track changes to settings without losing data when switching categories
self.dirty_settings = dict(self.settings)
self.selected_category = "General"
# Track changes to settings without losing data when switching categories
self.dirty_settings: dict = {}

def compose(self) -> ComposeResult:
yield Header(show_clock=False)
Expand Down