pub struct Settings {
pub default_provider: Option<String>,
pub default_model: Option<String>,
pub default_thinking_level: Option<String>,
pub tools: Vec<String>,
pub exclude_tools: Vec<String>,
pub theme: Option<String>,
pub verbose: bool,
pub hide_thinking: Option<bool>,
pub collapse_tool_output: Option<bool>,
pub auto_compact: Option<bool>,
pub compact_reserve_tokens: Option<u64>,
pub compact_keep_recent_tokens: Option<u64>,
/* private fields */
}Expand description
Settings schema matching pi’s settings.json format. API keys live in auth.json, not here.
Fields§
§default_provider: Option<String>§default_model: Option<String>§default_thinking_level: Option<String>§tools: Vec<String>§exclude_tools: Vec<String>§theme: Option<String>§verbose: bool§hide_thinking: Option<bool>Hide thinking blocks (Ctrl+T toggle). Persisted to settings.json.
collapse_tool_output: Option<bool>Collapse tool output (Ctrl+O toggle). Persisted to settings.json.
auto_compact: Option<bool>Auto-compact enabled (Ctrl+Shift+C toggle).
compact_reserve_tokens: Option<u64>Tokens to reserve for system prompt + tool defs + response.
compact_keep_recent_tokens: Option<u64>Number of most-recent tokens to always keep.
Implementations§
Source§impl Settings
impl Settings
Sourcepub fn set_hide_thinking(&mut self, value: Option<bool>)
pub fn set_hide_thinking(&mut self, value: Option<bool>)
Set hide_thinking and mark it as modified.
Sourcepub fn set_collapse_tool_output(&mut self, value: Option<bool>)
pub fn set_collapse_tool_output(&mut self, value: Option<bool>)
Set collapse_tool_output and mark it as modified.
Sourcepub fn set_default_thinking_level(&mut self, value: Option<String>)
pub fn set_default_thinking_level(&mut self, value: Option<String>)
Set default_thinking_level and mark it as modified.
Sourcepub fn set_auto_compact(&mut self, value: Option<bool>)
pub fn set_auto_compact(&mut self, value: Option<bool>)
Set auto_compact and mark it as modified.
Sourcepub fn set_compact_reserve_tokens(&mut self, value: Option<u64>)
pub fn set_compact_reserve_tokens(&mut self, value: Option<u64>)
Set compact_reserve_tokens and mark it as modified.
Sourcepub fn set_compact_keep_recent_tokens(&mut self, value: Option<u64>)
pub fn set_compact_keep_recent_tokens(&mut self, value: Option<u64>)
Set compact_keep_recent_tokens and mark it as modified.
Sourcepub fn load(cwd: &Path) -> Result<Self>
pub fn load(cwd: &Path) -> Result<Self>
Load settings from the global agent config path and project-local path.
Sourcepub fn load_from(global_path: PathBuf, cwd: &Path) -> Result<Self>
pub fn load_from(global_path: PathBuf, cwd: &Path) -> Result<Self>
Load settings with an explicit global config path (for testing).
Sourcepub fn save(&mut self) -> Result<()>
pub fn save(&mut self) -> Result<()>
Save only the modified fields to the global config path. Unmodified fields are never written, preventing project-level overrides and default values from leaking into the global file.
After a successful save, modified_fields is cleared so that
subsequent saves only write fields that changed since the last
write. This prevents stale modifications from being re-applied
when a different field is toggled later.
Uses file locking (flock on the .json.lock file) to prevent
corruption when multiple rab processes access the same file.
Atomic write via temp-file + rename prevents partial writes.
Sourcepub fn save_to(&mut self, path: PathBuf) -> Result<()>
pub fn save_to(&mut self, path: PathBuf) -> Result<()>
Save only the modified fields to a specific path (for testing). Uses file locking and atomic write (temp file + rename).