2026-02-27 04:29:51 +00:00
use serde ::{ Deserialize , Serialize };
2026-08-09 16:55:28 -07:00
use super ::gateway_settings ::GatewaySettings ;
2026-04-16 08:46:03 -07:00
use super ::project ::{ ClaudeCodeSettings , EnvVar };
2026-03-01 01:21:33 +00:00
2026-02-28 21:18:33 +00:00
fn default_true () -> bool {
true
}
2026-03-01 01:21:33 +00:00
fn default_global_instructions () -> Option < String > {
2026-03-01 14:36:51 +00:00
Some ( "If the project is not initialized with git, recommend to the user to initialize and use git to track changes. This makes it easier to revert should something break. \n\n Use subagents frequently. For long-running tasks, break the work into parallel subagents where possible. When handling multiple separate tasks, delegate each to its own subagent so they can run concurrently." . to_string ())
2026-03-01 01:21:33 +00:00
}
2026-02-27 15:22:49 +00:00
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "snake_case" )]
pub enum ImageSource {
Registry ,
LocalBuild ,
Custom ,
}
impl Default for ImageSource {
fn default () -> Self {
Self ::Registry
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GlobalAwsSettings {
#[serde(default)]
pub aws_config_path : Option < String > ,
#[serde(default)]
pub aws_profile : Option < String > ,
#[serde(default)]
pub aws_region : Option < String > ,
2026-05-24 08:49:06 -07:00
#[serde(default)]
pub default_model_id : Option < String > ,
2026-02-27 15:22:49 +00:00
}
impl Default for GlobalAwsSettings {
fn default () -> Self {
Self {
aws_config_path : None ,
aws_profile : None ,
aws_region : None ,
2026-05-24 08:49:06 -07:00
default_model_id : None ,
2026-02-27 15:22:49 +00:00
}
}
}
2026-05-24 08:49:06 -07:00
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct GlobalOllamaSettings {
#[serde(default)]
pub base_url : Option < String > ,
#[serde(default)]
pub default_model_id : Option < String > ,
2026-08-09 16:55:28 -07:00
/// Global fallback for the `haiku` alias override. Blank means "use the
/// resolved model id", which is what makes background Claude Code calls
/// work against a server that only serves one model.
#[serde(default)]
pub default_haiku_model_id : Option < String > ,
}
/// Global defaults for the llama.cpp (`llama-server`) backend.
/// Mirrors [`GlobalOllamaSettings`]; used when the per-project field is blank.
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct GlobalLlamaCppSettings {
#[serde(default)]
pub base_url : Option < String > ,
#[serde(default)]
pub default_model_id : Option < String > ,
#[serde(default)]
pub default_haiku_model_id : Option < String > ,
2026-05-24 08:49:06 -07:00
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct GlobalOpenAiCompatibleSettings {
#[serde(default)]
pub base_url : Option < String > ,
#[serde(default)]
pub default_model_id : Option < String > ,
2026-08-09 16:55:28 -07:00
#[serde(default)]
pub default_haiku_model_id : Option < String > ,
2026-05-24 08:49:06 -07:00
}
2026-02-27 04:29:51 +00:00
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AppSettings {
2026-02-27 15:22:49 +00:00
#[serde(default)]
2026-02-27 04:29:51 +00:00
pub default_ssh_key_path : Option < String > ,
2026-08-10 10:40:21 -07:00
/// Path to the organisation's root CA — a single certificate file or a
/// directory of them. Mounted read-only into every container, which then
/// installs it into the system trust store, Node's `NODE_EXTRA_CA_CERTS`,
/// Python's `REQUESTS_CA_BUNDLE`/`SSL_CERT_FILE` and Chrome's NSS database.
/// Required when the host sits behind a TLS-terminating corporate proxy.
/// Overridden per project by `Project::ca_cert_path`.
#[serde(default)]
pub ca_cert_path : Option < String > ,
2026-02-27 15:22:49 +00:00
#[serde(default)]
2026-02-27 04:29:51 +00:00
pub default_git_user_name : Option < String > ,
2026-02-27 15:22:49 +00:00
#[serde(default)]
2026-02-27 04:29:51 +00:00
pub default_git_user_email : Option < String > ,
2026-02-27 15:22:49 +00:00
#[serde(default)]
2026-02-27 04:29:51 +00:00
pub docker_socket_path : Option < String > ,
2026-02-27 15:22:49 +00:00
#[serde(default)]
pub image_source : ImageSource ,
#[serde(default)]
pub custom_image_name : Option < String > ,
#[serde(default)]
pub global_aws : GlobalAwsSettings ,
2026-05-24 08:49:06 -07:00
#[serde(default)]
pub global_ollama : GlobalOllamaSettings ,
#[serde(default)]
2026-08-09 16:55:28 -07:00
pub global_llamacpp : GlobalLlamaCppSettings ,
#[serde(default)]
2026-05-24 08:49:06 -07:00
pub global_openai_compatible : GlobalOpenAiCompatibleSettings ,
2026-03-01 01:21:33 +00:00
#[serde(default = "default_global_instructions" )]
2026-02-27 18:39:20 -08:00
pub global_claude_instructions : Option < String > ,
2026-03-01 01:21:33 +00:00
#[serde(default)]
pub global_custom_env_vars : Vec < EnvVar > ,
2026-02-28 21:18:33 +00:00
#[serde(default = "default_true" )]
pub auto_check_updates : bool ,
#[serde(default)]
pub dismissed_update_version : Option < String > ,
2026-03-01 15:57:22 +00:00
#[serde(default)]
pub timezone : Option < String > ,
2026-03-05 06:15:47 -08:00
#[serde(default)]
pub default_microphone : Option < String > ,
2026-03-12 09:26:58 -07:00
#[serde(default)]
pub dismissed_image_digest : Option < String > ,
2026-03-17 19:31:16 -07:00
#[serde(default)]
pub web_terminal : WebTerminalSettings ,
2026-04-12 20:02:39 -07:00
#[serde(default)]
pub stt : SttSettings ,
2026-04-16 08:46:03 -07:00
#[serde(default)]
2026-08-09 16:55:28 -07:00
pub gateway : GatewaySettings ,
#[serde(default)]
2026-04-16 08:46:03 -07:00
pub global_claude_code_settings : Option < ClaudeCodeSettings > ,
2026-08-28 12:51:18 -07:00
/// Whether the terminal loads `@xterm/addon-webgl`.
///
/// `None` is "auto", and auto is not the same answer on every platform.
/// On Linux the app disables WebKitGTK's DMA-BUF renderer at startup (see
/// `apply_webkit_wayland_workaround` in `main.rs`, and triple-c#34), which
/// does not remove WebGL — it leaves it backed by software rasterisation.
/// The addon therefore loads successfully and then renders every frame on
/// the CPU, which is slower than the canvas renderer it would otherwise
/// have fallen back to. So auto means enabled on macOS and Windows, and
/// disabled on Linux.
///
/// `Some(true)` / `Some(false)` force it either way on any platform. A
/// Linux user running X11, or one whose driver stack is unaffected, can
/// turn it back on; anyone seeing terminal lag can turn it off without
/// waiting for a release. Deliberately `Option<bool>` rather than `bool`:
/// the zero value has to mean "we choose", not "off", or every existing
/// settings file would silently pin the answer at whatever the default was
/// the day it was written.
#[serde(default)]
pub terminal_gpu_rendering : Option < bool > ,
2026-04-12 20:02:39 -07:00
}
fn default_stt_model () -> String {
"tiny" . to_string ()
}
fn default_stt_port () -> u16 {
9876
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SttSettings {
#[serde(default)]
pub enabled : bool ,
#[serde(default = "default_stt_model" )]
pub model : String ,
#[serde(default = "default_stt_port" )]
pub port : u16 ,
#[serde(default)]
pub language : Option < String > ,
}
impl Default for SttSettings {
fn default () -> Self {
Self {
enabled : false ,
model : default_stt_model (),
port : 9876 ,
language : None ,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SttStatus {
pub container_exists : bool ,
pub running : bool ,
pub port : u16 ,
pub model : String ,
pub image_exists : bool ,
2026-03-17 19:31:16 -07:00
}
fn default_web_terminal_port () -> u16 {
7681
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WebTerminalSettings {
#[serde(default)]
pub enabled : bool ,
#[serde(default = "default_web_terminal_port" )]
pub port : u16 ,
#[serde(default)]
pub access_token : Option < String > ,
}
impl Default for WebTerminalSettings {
fn default () -> Self {
Self {
enabled : false ,
port : 7681 ,
access_token : None ,
}
}
2026-02-27 04:29:51 +00:00
}
impl Default for AppSettings {
fn default () -> Self {
Self {
default_ssh_key_path : None ,
2026-08-10 10:40:21 -07:00
ca_cert_path : None ,
2026-02-27 04:29:51 +00:00
default_git_user_name : None ,
default_git_user_email : None ,
docker_socket_path : None ,
2026-02-27 15:22:49 +00:00
image_source : ImageSource ::default (),
custom_image_name : None ,
global_aws : GlobalAwsSettings ::default (),
2026-05-24 08:49:06 -07:00
global_ollama : GlobalOllamaSettings ::default (),
2026-08-09 16:55:28 -07:00
global_llamacpp : GlobalLlamaCppSettings ::default (),
2026-05-24 08:49:06 -07:00
global_openai_compatible : GlobalOpenAiCompatibleSettings ::default (),
2026-03-01 01:21:33 +00:00
global_claude_instructions : default_global_instructions (),
global_custom_env_vars : Vec ::new (),
2026-02-28 21:18:33 +00:00
auto_check_updates : true ,
dismissed_update_version : None ,
2026-03-01 15:57:22 +00:00
timezone : None ,
2026-03-05 06:15:47 -08:00
default_microphone : None ,
2026-03-12 09:26:58 -07:00
dismissed_image_digest : None ,
2026-03-17 19:31:16 -07:00
web_terminal : WebTerminalSettings ::default (),
2026-04-12 20:02:39 -07:00
stt : SttSettings ::default (),
2026-08-09 16:55:28 -07:00
gateway : GatewaySettings ::default (),
2026-04-16 08:46:03 -07:00
global_claude_code_settings : None ,
2026-08-28 12:51:18 -07:00
terminal_gpu_rendering : None ,
2026-02-27 04:29:51 +00:00
}
}
}