layout source from main

This commit is contained in:
2026-06-13 10:49:41 +07:00
parent 8c111f2406
commit 853acefac1
25 changed files with 1848 additions and 1463 deletions

View File

@@ -0,0 +1,49 @@
#pragma once
#include "app/app_state.hpp"
#include <nlohmann/json.hpp>
#include <filesystem>
#include <optional>
#include <string>
namespace lm {
class StateRepository
{
public:
explicit StateRepository(std::filesystem::path data_path);
AppState& app() { return app_; }
const AppState& app() const { return app_; }
bool load();
bool save() const;
bool saveAppState();
void ensureSchema();
bool saveProfile(const nlohmann::json& profile);
void reloadActiveCache();
bool deleteProfile(const std::string& id);
std::optional<nlohmann::json> loadProfileById(const std::string& id) const;
private:
AppState app_;
std::filesystem::path modelsDir() const;
std::filesystem::path profileFilePath(const std::string& id) const;
std::optional<nlohmann::json> loadProfileFromDisk(const std::string& id) const;
bool saveProfileToDisk(const nlohmann::json& profile) const;
bool deleteProfileFile(const std::string& id) const;
void loadActiveCache();
bool persistActiveProfile();
nlohmann::json globalStateForDisk(const nlohmann::json& state) const;
void stripInlineProfiles(nlohmann::json& state) const;
void migrateStorage();
void bootstrapDefaultState();
};
} // namespace lm