Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 26, 2025

This PR addresses the need for a proper database system to replace configuration file storage in AppData. KAST now uses SQLite with Entity Framework Core for robust application settings management with auto-save functionality and synchronized theme management.

Auto-save Settings Working

Problem Solved

Previously, KAST relied on configuration files stored in AppData (similar to FASTER), which created several issues:

  • No centralized configuration management
  • Difficult to track and maintain application settings
  • Limited validation and type safety for configuration values
  • No environment variable override capabilities
  • Manual save operations required for settings changes
  • Theme state not synchronized between UI components

Solution

Implemented a focused SQLite database system with Entity Framework Core 9.0 that provides:

Database Models

  • KastSettings - Enhanced application settings model with comprehensive configuration options
  • Server - Basic server information storage

Enhanced Settings Features

  • Theme Mode - Light/Dark/Auto theme selection with system preference detection
  • Language Support - Multi-language interface (English, French, German, Spanish)
  • Update Management - Configurable automatic update checking
  • Debug Options - Toggle debug logging for troubleshooting
  • Path Configuration - Mod folder and server default paths
  • API Integration - Steam API key management
  • Theme Customization - Accent color configuration

Key Features

  • Zero-install database - SQLite is embedded, requiring no external dependencies
  • Environment variable overrides - All settings can be controlled via environment variables
  • Automatic migrations - Schema versioning and updates handled by Entity Framework
  • Development/Production separation - Different database files for different environments
  • Type-safe configuration - Strongly typed settings with validation
  • Auto-save functionality - Settings persist automatically without manual save operations
  • Theme synchronization - Theme state synchronized between header toggle and settings page

User Interface

Enhanced Settings page with professional UI components and modern UX:

  • Auto-save - No save button required, settings persist immediately on change
  • Real-time feedback - Success notifications confirm changes are saved
  • Theme synchronization - Header theme toggle and settings dropdown stay synchronized
  • Dropdown selectors for theme mode and language
  • Checkbox controls for boolean settings
  • File browser integration for path selection

Theme Management

Implemented comprehensive theme management system:

  • ThemeService - Manages bidirectional sync between database and UI state
  • MainLayout integration - Theme toggle button connected to database via ThemeService
  • Settings page sync - Theme dropdown synchronized with MainLayout's _isDarkMode
  • Event-driven updates - Real-time theme changes across entire application

Technical Implementation

The database uses Entity Framework Core with SQLite provider, stored in %LocalAppData%/KAST/KAST.db (or KAST-dev.db in development). The migration system ensures schema updates are handled automatically.

Configuration management is handled through the existing ConfigService with full support for environment variable overrides. The new ThemeService provides centralized theme state management with automatic synchronization between database settings and UI components.

Auto-save functionality is implemented using @bind-Value:after event handlers for immediate persistence without user intervention.

Testing

The implementation has been thoroughly tested with:

  • Successful build and migration execution
  • Enhanced Settings page functionality validation
  • Auto-save feature verification across all setting types
  • Theme synchronization between header toggle and settings page
  • Environment variable override verification
  • Database persistence and retrieval operations

This database system provides a solid foundation for application configuration management with modern UX patterns including auto-save and synchronized theme management, while maintaining a clean, focused scope that can be extended for future features as needed.

Fixes #3


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 2 commits September 26, 2025 07:23
Co-authored-by: Foxlider <19773387+Foxlider@users.noreply.github.com>
…ork Core

Co-authored-by: Foxlider <19773387+Foxlider@users.noreply.github.com>
Copilot AI changed the title [WIP] [FEATURE] A proper database system Implement proper database system with SQLite and Entity Framework Core Sep 26, 2025
Copilot AI requested a review from Foxlider September 26, 2025 07:33
Copy link
Owner

@Foxlider Foxlider left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot
Remove created folders that contain the .cfg and Arma3Profiles. THose are build artifacts

Don't manage the mods or servers and profiles yet
Just take care of the settings system to store config values.

Might have to add more config entries too for Blazor theme config for example, remember light or dark mode...

@Foxlider
Copy link
Owner

@copilot
Remove created folders that contain the .cfg and Arma3Profiles. THose are build artifacts

Don't manage the mods or servers and profiles yet
Just take care of the settings system to store config values.

Might have to add more config entries too for Blazor theme config for example, remember light or dark mode...

Co-authored-by: Foxlider <19773387+Foxlider@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Sep 26, 2025

@copilot
Remove created folders that contain the .cfg and Arma3Profiles. THose are build artifacts

...

Done! I've addressed all your feedback:

Removed build artifact folders - Deleted the 3b7d876b-a563-6e50-befb-76657ecf4671 and c50e6d0f-cf1c-5357-ad9c-298407844f2d directories containing .cfg and Arma3Profile files

Focused on settings system only - Removed all complex mod/profile management (Mod, Profile, ModProfile, ProfileHistory models and services), reverted Mods page to original state

Enhanced settings with theme config - Added Theme Mode (light/dark/auto), Language selection, Check for Updates, and Debug Logging options

The database now properly focuses on configuration settings only, with an enhanced Settings page that includes the theme configuration you requested. Screenshot shows the new interface with dropdowns for theme mode and language, plus checkboxes for the other options.

Commit: 23a84a0

Copilot AI changed the title Implement proper database system with SQLite and Entity Framework Core Implement database system for application settings with SQLite and Entity Framework Core Sep 26, 2025
Copilot AI requested a review from Foxlider September 26, 2025 08:19
Copy link
Owner

@Foxlider Foxlider left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot

  1. Auto-save settings
  2. Light and Dark in the settings should be tied to the setting _isDarkMode in MainLayout.razor

Co-authored-by: Foxlider <19773387+Foxlider@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Sep 26, 2025

@copilot

  1. Auto-save settings
  2. Light and Dark in the settings should be tied to the setting _isDarkMode in MainLayout.razor

Both features implemented successfully!

Auto-save settings - Removed the Save button, settings now save automatically when any field changes with immediate user feedback

Theme mode tied to MainLayout's _isDarkMode - Created ThemeService that syncs the database theme setting with the MainLayout's _isDarkMode variable. Both the header theme toggle and settings dropdown now update the same database value and stay synchronized.

Auto-save Settings

Screenshot shows the enhanced settings page with auto-save notifications and theme mode properly synchronized between the dropdown and the header toggle button.

Commit: 4005f82

Copilot AI changed the title Implement database system for application settings with SQLite and Entity Framework Core Implement database system for application settings with auto-save and theme synchronization Sep 26, 2025
Copilot AI requested a review from Foxlider September 26, 2025 09:02
@sonarqubecloud
Copy link

@Foxlider Foxlider marked this pull request as ready for review September 26, 2025 09:21
@Foxlider Foxlider merged commit aa79263 into main Sep 26, 2025
6 checks passed
@Foxlider Foxlider deleted the copilot/fix-d145dc3b-9e44-4305-a173-387c99e49f22 branch September 26, 2025 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] A proper database system

2 participants