This commit is contained in:
2026-09-04 08:16:05 +07:00
parent 212f35d6bb
commit 17de4f6376
43 changed files with 376 additions and 721 deletions
+9 -10
View File
@@ -2,8 +2,8 @@ use std::path::PathBuf;
use serde::{Deserialize, Serialize};
/// The default grasp servers.
/// Offered while the user has not published a grasp list, kind `10317`.
/// The default grasp servers,
/// offered while the user has not published a grasp list.
pub const DEFAULT_GRASP_SERVERS: [&str; 3] = [
"wss://relay.ngit.dev",
"wss://gitnostr.com",
@@ -23,10 +23,8 @@ pub enum AppearanceMode {
Dark,
}
/// Theme configuration.
/// Fields mirror the gpui-component `Theme` surface customized at startup.
/// Applying the settings is then a field-for-field copy.
/// Theme names identify entries in the gpui-component theme registry.
/// Theme configuration,
/// fields mirror the gpui-component `Theme` surface customized at startup.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct ThemeSettings {
@@ -86,8 +84,8 @@ impl Default for GraspServersSettings {
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct LocalReposSettings {
/// The directories scanned for local git repositories.
/// Defaults to the user's Desktop and Documents folders.
/// The directories scanned for local git repositories,
/// defaults to the user's Desktop and Documents folders.
pub scan_paths: Vec<PathBuf>,
}
@@ -103,8 +101,9 @@ impl Default for LocalReposSettings {
}
}
/// A remembered association between a local checkout folder and an announced repository.
/// Recorded when the user clones a repository or picks a folder in the New PR panel.
/// A remembered association between a local checkout folder and an announced repository,
/// recorded when the user clones a repository or picks a folder in the New PR panel.
///
/// The panel can then prefill the folder later without asking again.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(default)]
+8 -6
View File
@@ -9,7 +9,9 @@ struct GlobalSettingsStore(Entity<SettingsStore>);
impl Global for GlobalSettingsStore {}
/// The application settings, loaded from disk at startup and saved whenever they change.
/// The application settings,
/// loaded from disk at startup and saved whenever they change.
///
/// Installed as a global by the app so any part of the UI can read and edit them.
pub struct SettingsStore {
path: PathBuf,
@@ -27,10 +29,11 @@ impl SettingsStore {
cx.set_global(GlobalSettingsStore(entity));
}
/// Load the settings from `path`.
/// Falls back to defaults when the file is missing or unreadable.
/// Missing keys merge with the defaults.
/// Older settings files keep working as new settings are added.
/// Load the settings from `path`,
/// falls back to defaults when the file is missing or unreadable.
///
/// Missing keys merge with the defaults,
/// older settings files keep working as new settings are added.
pub fn new(path: impl AsRef<Path>, _cx: &mut Context<Self>) -> Self {
Self {
path: path.as_ref().to_path_buf(),
@@ -80,7 +83,6 @@ impl SettingsStore {
}
/// Write the settings to disk, replacing the file atomically.
/// A crash mid-write cannot corrupt the settings.
fn save(&self) -> Result<()> {
if let Some(parent) = self.path.parent() {
std::fs::create_dir_all(parent)?;