assistant_settings.rs

 1use anyhow;
 2use schemars::JsonSchema;
 3use serde::{Deserialize, Serialize};
 4use settings::Setting;
 5
 6#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
 7#[serde(rename_all = "snake_case")]
 8pub enum AssistantDockPosition {
 9    Left,
10    Right,
11    Bottom,
12}
13
14#[derive(Deserialize, Debug)]
15pub struct AssistantSettings {
16    pub dock: AssistantDockPosition,
17    pub default_width: f32,
18    pub default_height: f32,
19}
20
21#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug)]
22pub struct AssistantSettingsContent {
23    pub dock: Option<AssistantDockPosition>,
24    pub default_width: Option<f32>,
25    pub default_height: Option<f32>,
26}
27
28impl Setting for AssistantSettings {
29    const KEY: Option<&'static str> = Some("assistant");
30
31    type FileContent = AssistantSettingsContent;
32
33    fn load(
34        default_value: &Self::FileContent,
35        user_values: &[&Self::FileContent],
36        _: &gpui::AppContext,
37    ) -> anyhow::Result<Self> {
38        Self::load_via_json_merge(default_value, user_values)
39    }
40}