Expand description
Persistence operations backed by a plain JSON file.
Settings are stored at ~/.config/gitkraft/settings.json (or the
platform-appropriate config directory). Writes are atomic: content is
first written to a NamedTempFile in the same directory and then
persist()-ed into place, so a crash mid-write can never produce a
corrupted file and no stale .tmp file is ever left behind.
GUI settings are stored in settings.json; TUI settings are stored in
tui-settings.json. The two files are independent so each UI can evolve
its own preferences (theme index, session, etc.) without stomping the other.
Functionsยง
- get_
last_ repo - Return the last opened repository path, if any.
- get_
last_ tui_ repo - Return the last TUI-opened repository path, if any.
- get_
saved_ editor - Return the saved editor name, if any.
- get_
saved_ layout - Return saved layout preferences, if any.
- get_
saved_ theme - Return the saved theme name, if any.
- load_
settings - Load GUI application settings.
- load_
tui_ settings - Load TUI application settings from
tui-settings.json. - record_
repo_ and_ save_ session - Record that a repo was opened AND update the open-tab session in a single write (saves one round-trip to disk).
- record_
repo_ opened - Record that a repository was opened (updates history +
last_repo). - record_
repo_ opened_ tui - Record that a repository was opened in the TUI.
- save_
editor - Persist the selected editor name.
- save_
editor_ tui - Persist the TUI editor selection.
- save_
layout - Persist layout preferences.
- save_
session - Persist the open-tab session without modifying the recent-repos list.
- save_
session_ tui - Persist the TUI open-tab session.
- save_
settings - Persist GUI application settings to
settings.jsonusing an atomic write. - save_
theme - Persist the selected theme name.
- save_
theme_ tui - Persist the TUI theme selection.
- save_
tui_ settings - Persist TUI application settings to
tui-settings.jsonusing an atomic write. - settings_
dir - Returns the settings directory (
~/.config/gitkraft/or equivalent). - settings_
json_ path - Full path to the GUI JSON settings file (public so frontends can open it in an editor).
- tui_
settings_ json_ path - Full path to the TUI-specific JSON settings file (public so the TUI can open it in an editor).
- update_
settings - Apply a closure to GUI settings and persist the result in a single read-modify-write cycle. Avoids duplicating the load โ mutate โ save pattern across every individual setting helper.
- update_
tui_ settings - Apply a closure to TUI settings and persist the result in a single read-modify-write cycle.