| 1 | //! One declaration per setting: type, default, and an optional `ui` block. |
| 2 | //! |
| 3 | //! # What this replaces |
| 4 | //! |
| 5 | //! This table is the single source that the settings surface projects. It |
| 6 | //! replaces, and is the reason for deleting, these hand-maintained key tables |
| 7 | //! that used to live beside `ConfigView` in `crates/tui/src/tui/views/mod.rs`: |
| 8 | //! |
| 9 | //! - the `Vec<ConfigRow>` literal's `section:` field (row → heading), |
| 10 | //! and `ConfigCategory::for_section` / `ConfigRowFacts::category` |
| 11 | //! (row → rail tab), |
| 12 | //! - `config_boolean_key` and `config_integer_key` (key → editor kind), |
| 13 | //! - `config_choice_values` (key → enum values), |
| 14 | //! - `config_choice_label` / `config_choice_detail` (value → label/detail), |
| 15 | //! - `config_label_message` (key → label string), |
| 16 | //! - `config_hint_for_key` (key → description string). |
| 17 | //! |
| 18 | //! # The rule |
| 19 | //! |
| 20 | //! A setting is declared once, here. `ui: Some(..)` puts it on the settings |
| 21 | //! screen; `ui: None` keeps the declaration (type, default, and the fact that |
| 22 | //! the key is known) without giving it a row. Visibility is a property of the |
| 23 | //! declaration, not of the renderer. |
| 24 | //! |
| 25 | //! `label`, `description`, and the per-value `label`/`description` are |
| 26 | //! *message keys*, not prose: the localization pack owns the text in fifteen |
| 27 | //! languages, this table owns which string a setting shows. An empty key means |
| 28 | //! "no string" — the surface humanizes the setting key instead. |
| 29 | //! |
| 30 | //! `tab` and `group` are ids the settings screen resolves to its rail |
| 31 | //! categories and section headings. Declaration order is render order: |
| 32 | //! distinct tabs appear in the order they are first declared, groups in the |
| 33 | //! order they are first declared within a tab, and rows in declaration order |
| 34 | //! within a group. |
| 35 | //! |
| 36 | //! Two settings take their values from a runtime registry rather than this |
| 37 | //! table (`theme` from the shipped palettes, `locale` from the shipped packs). |
| 38 | //! They are declared `String`; the surface supplies the live value list. |
| 39 | //! `reasoning_effort` declares the canonical nine-spelling effort vocabulary |
| 40 | //! here so `/config` and `/effort` cannot disagree; the live settings screen |
| 41 | //! still narrows that list to the active route's rungs. |
| 42 | |
| 43 | /// Fresh terminal installs, theme resets and the settings schema share this default. |
| 44 | pub const DEFAULT_TUI_THEME: &str = "underwater"; |
| 45 | |
| 46 | /// One selectable value of a [`SettingKind::Enum`] (or a boolean override). |
| 47 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
| 48 | pub struct SettingOption { |
| 49 | pub value: &'static str, |
| 50 | /// Message key for the value's label; empty means "show the raw value". |
| 51 | pub label: &'static str, |
| 52 | /// Message key for the value's one-line detail; empty means none. |
| 53 | pub description: &'static str, |
| 54 | } |
| 55 | |
| 56 | impl SettingOption { |
| 57 | const fn new(value: &'static str, label: &'static str, description: &'static str) -> Self { |
| 58 | Self { |
| 59 | value, |
| 60 | label, |
| 61 | description, |
| 62 | } |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | /// The value type of a setting, and for closed value sets, the values. |
| 67 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
| 68 | pub enum SettingKind { |
| 69 | /// `true` / `false`. An empty option slice means the surface's default |
| 70 | /// on/off labels; a non-empty one overrides them per value. |
| 71 | Bool(&'static [SettingOption]), |
| 72 | Int, |
| 73 | /// A fractional number such as a percent threshold. Values are served and |
| 74 | /// accepted in plain decimal form; bounds live in the write validator. |
| 75 | Float, |
| 76 | Enum(&'static [SettingOption]), |
| 77 | String, |
| 78 | } |
| 79 | |
| 80 | /// What a declared settings row is. `Setting` is a writable preference; |
| 81 | /// `Action` opens another surface (the provider/model pickers, module |
| 82 | /// links); `Diagnostic` is a read-only receipt or managed-policy fact; |
| 83 | /// `Session` is editable for the running session but does not persist |
| 84 | /// through the config store. |
| 85 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
| 86 | pub enum SettingRowKind { |
| 87 | Setting, |
| 88 | Action, |
| 89 | Diagnostic, |
| 90 | Session, |
| 91 | } |
| 92 | |
| 93 | /// Where a setting appears, and what it says. Absent ⇒ no row. |
| 94 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
| 95 | pub struct SettingUi { |
| 96 | pub tab: &'static str, |
| 97 | pub group: &'static str, |
| 98 | /// Message key for the row label; empty ⇒ humanize the setting key. |
| 99 | pub label: &'static str, |
| 100 | /// Message key for the row's description sentence. |
| 101 | pub description: &'static str, |
| 102 | /// Whether the row is a writable preference, a link to another surface, |
| 103 | /// a read-only receipt, or a session-scoped override. Surfaces that |
| 104 | /// cannot open the target or scope the write render non-`Setting` rows |
| 105 | /// read-only instead of guessing. |
| 106 | pub row: SettingRowKind, |
| 107 | } |
| 108 | |
| 109 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
| 110 | pub struct SettingDef { |
| 111 | pub key: &'static str, |
| 112 | pub kind: SettingKind, |
| 113 | /// The value in force when nothing is configured, as it is written to |
| 114 | /// disk. Empty for session-owned rows, actions, and receipts. |
| 115 | pub default: &'static str, |
| 116 | pub ui: Option<SettingUi>, |
| 117 | } |
| 118 | |
| 119 | impl SettingDef { |
| 120 | /// The closed value set, when this setting has one. `None` means the |
| 121 | /// surface supplies values (free text, an integer, or a runtime registry). |
| 122 | pub fn values(&self) -> Option<Vec<&'static str>> { |
| 123 | match self.kind { |
| 124 | SettingKind::Bool(_) => Some(vec!["false", "true"]), |
| 125 | SettingKind::Enum(options) => Some(options.iter().map(|o| o.value).collect()), |
| 126 | SettingKind::Int | SettingKind::String | SettingKind::Float => None, |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | /// Per-value label/description metadata for `value`, when declared. |
| 131 | pub fn option(&self, value: &str) -> Option<&'static SettingOption> { |
| 132 | let options = match self.kind { |
| 133 | SettingKind::Bool(options) | SettingKind::Enum(options) => options, |
| 134 | SettingKind::Int | SettingKind::String | SettingKind::Float => return None, |
| 135 | }; |
| 136 | options.iter().find(|option| option.value == value) |
| 137 | } |
| 138 | |
| 139 | pub fn is_bool(&self) -> bool { |
| 140 | matches!(self.kind, SettingKind::Bool(_)) |
| 141 | } |
| 142 | |
| 143 | pub fn is_int(&self) -> bool { |
| 144 | matches!(self.kind, SettingKind::Int) |
| 145 | } |
| 146 | |
| 147 | pub fn is_float(&self) -> bool { |
| 148 | matches!(self.kind, SettingKind::Float) |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | const NOTIFICATION_SOUNDS: &[SettingOption] = &[ |
| 153 | SettingOption::new("legacy", "ConfigChoiceNotificationLegacy", ""), |
| 154 | SettingOption::new("off", "ConfigValueOff", ""), |
| 155 | SettingOption::new("whale", "ConfigChoiceNotificationWhale", ""), |
| 156 | SettingOption::new("bell", "ConfigChoiceNotificationBell", ""), |
| 157 | SettingOption::new("beep", "ConfigChoiceNotificationBell", ""), |
| 158 | SettingOption::new("file", "ConfigChoiceNotificationFile", ""), |
| 159 | ]; |
| 160 | |
| 161 | const NOTIFICATION_COMPLETION_SOUNDS: &[SettingOption] = &[ |
| 162 | SettingOption::new("off", "ConfigValueOff", ""), |
| 163 | SettingOption::new("whale", "ConfigChoiceNotificationWhale", ""), |
| 164 | SettingOption::new("bell", "ConfigChoiceNotificationBell", ""), |
| 165 | SettingOption::new("beep", "ConfigChoiceNotificationBell", ""), |
| 166 | SettingOption::new("file", "ConfigChoiceNotificationFile", ""), |
| 167 | ]; |
| 168 | |
| 169 | const NOTIFICATION_CONDITIONS: &[SettingOption] = &[ |
| 170 | SettingOption::new("always", "ConfigChoiceNotificationAlways", ""), |
| 171 | SettingOption::new("unfocused", "ConfigChoiceNotificationUnfocused", ""), |
| 172 | SettingOption::new("never", "ConfigChoiceNotificationNever", ""), |
| 173 | ]; |
| 174 | |
| 175 | const NOTIFICATION_METHODS: &[SettingOption] = &[ |
| 176 | SettingOption::new("auto", "", ""), |
| 177 | SettingOption::new("off", "", ""), |
| 178 | SettingOption::new("osc9", "", ""), |
| 179 | SettingOption::new("bel", "", ""), |
| 180 | SettingOption::new("kitty", "", ""), |
| 181 | SettingOption::new("ghostty", "", ""), |
| 182 | ]; |
| 183 | |
| 184 | const NOTIFICATION_SUBAGENTS: &[SettingOption] = &[ |
| 185 | SettingOption::new("off", "", ""), |
| 186 | SettingOption::new("final-only", "", ""), |
| 187 | SettingOption::new("always", "", ""), |
| 188 | ]; |
| 189 | |
| 190 | const ON_OFF: &[SettingOption] = &[]; |
| 191 | |
| 192 | const TELEMETRY: &[SettingOption] = &[ |
| 193 | SettingOption::new("false", "ConfigValueTelemetryOff", ""), |
| 194 | SettingOption::new("true", "ConfigValueTelemetryOn", ""), |
| 195 | ]; |
| 196 | |
| 197 | const LOW_MOTION: &[SettingOption] = &[ |
| 198 | SettingOption::new("false", "ConfigValueOff", "ConfigChoiceDetailLowMotionOff"), |
| 199 | SettingOption::new("true", "ConfigValueOn", "ConfigChoiceDetailLowMotionOn"), |
| 200 | ]; |
| 201 | |
| 202 | const FANCY_ANIMATIONS: &[SettingOption] = &[ |
| 203 | SettingOption::new("false", "ConfigValueOff", "ConfigChoiceDetailFancyOff"), |
| 204 | SettingOption::new("true", "ConfigValueOn", "ConfigChoiceDetailFancyOn"), |
| 205 | ]; |
| 206 | |
| 207 | const SHOW_THINKING: &[SettingOption] = &[ |
| 208 | SettingOption::new( |
| 209 | "false", |
| 210 | "ConfigValueOff", |
| 211 | "ConfigChoiceDetailShowThinkingOff", |
| 212 | ), |
| 213 | SettingOption::new("true", "ConfigValueOn", "ConfigChoiceDetailShowThinkingOn"), |
| 214 | ]; |
| 215 | |
| 216 | const THINKING_HIGHLIGHT: &[SettingOption] = &[ |
| 217 | SettingOption::new( |
| 218 | "false", |
| 219 | "ConfigValueOff", |
| 220 | "ConfigChoiceDetailThinkingHighlightOff", |
| 221 | ), |
| 222 | SettingOption::new( |
| 223 | "true", |
| 224 | "ConfigValueOn", |
| 225 | "ConfigChoiceDetailThinkingHighlightOn", |
| 226 | ), |
| 227 | ]; |
| 228 | |
| 229 | const PERMISSION_POSTURE: &[SettingOption] = &[ |
| 230 | SettingOption::new("ask", "ConfigChoiceAsk", "ConfigChoiceDetailAsk"), |
| 231 | SettingOption::new( |
| 232 | "accept-edits", |
| 233 | "ConfigChoiceAcceptEdits", |
| 234 | "ConfigChoiceDetailAcceptEdits", |
| 235 | ), |
| 236 | SettingOption::new( |
| 237 | "auto-review", |
| 238 | "ConfigChoiceAutoReview", |
| 239 | "ConfigChoiceDetailAutoReview", |
| 240 | ), |
| 241 | SettingOption::new( |
| 242 | "full-access", |
| 243 | "ConfigChoiceFullAccess", |
| 244 | "ConfigChoiceDetailFullAccess", |
| 245 | ), |
| 246 | ]; |
| 247 | |
| 248 | const APPROVAL_MODE: &[SettingOption] = &[ |
| 249 | SettingOption::new("ask", "ConfigChoiceAsk", "ConfigChoiceDetailAsk"), |
| 250 | SettingOption::new( |
| 251 | "accept-edits", |
| 252 | "ConfigChoiceAcceptEdits", |
| 253 | "ConfigChoiceDetailAcceptEdits", |
| 254 | ), |
| 255 | SettingOption::new( |
| 256 | "auto-review", |
| 257 | "ConfigChoiceAutoReview", |
| 258 | "ConfigChoiceDetailAutoReview", |
| 259 | ), |
| 260 | SettingOption::new( |
| 261 | "full-access", |
| 262 | "ConfigChoiceFullAccess", |
| 263 | "ConfigChoiceDetailFullAccess", |
| 264 | ), |
| 265 | ]; |
| 266 | |
| 267 | const APPROVAL_POLICY: &[SettingOption] = &[ |
| 268 | SettingOption::new( |
| 269 | "use-tui-default", |
| 270 | "ConfigChoiceUseTuiDefault", |
| 271 | "ConfigChoiceDetailUseTuiDefault", |
| 272 | ), |
| 273 | SettingOption::new("ask", "ConfigChoiceAsk", "ConfigChoiceDetailAsk"), |
| 274 | SettingOption::new( |
| 275 | "accept-edits", |
| 276 | "ConfigChoiceAcceptEdits", |
| 277 | "ConfigChoiceDetailAcceptEdits", |
| 278 | ), |
| 279 | SettingOption::new( |
| 280 | "auto-review", |
| 281 | "ConfigChoiceAutoReview", |
| 282 | "ConfigChoiceDetailAutoReview", |
| 283 | ), |
| 284 | SettingOption::new( |
| 285 | "full-access", |
| 286 | "ConfigChoiceFullAccess", |
| 287 | "ConfigChoiceDetailFullAccess", |
| 288 | ), |
| 289 | // `never` is a managed-policy value only: it is accepted from config.toml and |
| 290 | // shown read-only, never offered by the editor. |
| 291 | ]; |
| 292 | |
| 293 | const DEFAULT_MODE: &[SettingOption] = &[ |
| 294 | SettingOption::new( |
| 295 | "agent", |
| 296 | "ConfigChoiceModeAct", |
| 297 | "ConfigChoiceDetailModeAgent", |
| 298 | ), |
| 299 | SettingOption::new("plan", "ConfigChoiceModePlan", "ConfigChoiceDetailModePlan"), |
| 300 | ]; |
| 301 | |
| 302 | const FOCUS_TEXTURE: &[SettingOption] = &[ |
| 303 | SettingOption::new("off", "ConfigValueOff", ""), |
| 304 | SettingOption::new("scrim", "", ""), |
| 305 | SettingOption::new("grain", "", ""), |
| 306 | ]; |
| 307 | |
| 308 | const INLINE_DIFFS: &[SettingOption] = &[ |
| 309 | SettingOption::new("full", "ConfigChoiceDiffFull", ""), |
| 310 | SettingOption::new("summary", "ConfigChoiceDiffSummary", ""), |
| 311 | SettingOption::new("off", "ConfigValueOff", ""), |
| 312 | ]; |
| 313 | |
| 314 | const STATUS_INDICATOR: &[SettingOption] = &[ |
| 315 | // `whale` is retired: load migrates whale | 🐳 | 🐋 to the typographic |
| 316 | // mark, so the editor no longer offers it. |
| 317 | SettingOption::new("cw", "ConfigChoiceStatusCw", ""), |
| 318 | SettingOption::new("dots", "ConfigChoiceStatusDots", ""), |
| 319 | SettingOption::new("off", "ConfigValueOff", ""), |
| 320 | ]; |
| 321 | |
| 322 | const SYNCHRONIZED_OUTPUT: &[SettingOption] = &[ |
| 323 | SettingOption::new("auto", "", ""), |
| 324 | SettingOption::new("on", "", ""), |
| 325 | SettingOption::new("off", "", ""), |
| 326 | ]; |
| 327 | |
| 328 | const COST_CURRENCY: &[SettingOption] = &[ |
| 329 | SettingOption::new("usd", "", ""), |
| 330 | SettingOption::new("cny", "", ""), |
| 331 | ]; |
| 332 | |
| 333 | /// The canonical `ReasoningEffort::as_setting` spellings, in the order |
| 334 | /// `auto, off, minimal, low, medium, high, xhigh, ultra, max`. |
| 335 | /// |
| 336 | /// This is the same vocabulary `codewhale_tui::reasoning_preference:: |
| 337 | /// ReasoningEffort::parse_strict` accepts (`/effort`), so the settings schema |
| 338 | /// and the command cannot drift. Labels stay empty: an undeclared label means |
| 339 | /// "show the raw value", and a capitalized literal would also have to be |
| 340 | /// localized in every shipped locale to satisfy the schema message-key check. |
| 341 | /// Canonical setting value for a reasoning-effort spelling, accepting the |
| 342 | /// documented aliases. Unknown values are refused with the full vocabulary. |
| 343 | pub fn canonical_reasoning_effort(value: &str) -> Result<&'static str, String> { |
| 344 | let trimmed = value.trim(); |
| 345 | match trimmed.to_ascii_lowercase().as_str() { |
| 346 | "off" | "disabled" | "none" | "false" => Ok("off"), |
| 347 | "minimal" => Ok("minimal"), |
| 348 | "low" | "minimum" | "light" => Ok("low"), |
| 349 | "medium" | "mid" => Ok("medium"), |
| 350 | "high" => Ok("high"), |
| 351 | "xhigh" => Ok("xhigh"), |
| 352 | "auto" | "automatic" => Ok("auto"), |
| 353 | "ultra" | "ultracode" => Ok("ultra"), |
| 354 | "max" | "maximum" => Ok("max"), |
| 355 | _ => Err(format!( |
| 356 | "Unrecognized reasoning effort {trimmed:?}. Expected one of: auto, off, minimal, low, medium, high, xhigh, ultra, or max." |
| 357 | )), |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | const REASONING_EFFORT: &[SettingOption] = &[ |
| 362 | SettingOption::new("auto", "", ""), |
| 363 | SettingOption::new("off", "", ""), |
| 364 | SettingOption::new("minimal", "", ""), |
| 365 | SettingOption::new("low", "", ""), |
| 366 | SettingOption::new("medium", "", ""), |
| 367 | SettingOption::new("high", "", ""), |
| 368 | SettingOption::new("xhigh", "", ""), |
| 369 | SettingOption::new("ultra", "", ""), |
| 370 | SettingOption::new("max", "", ""), |
| 371 | ]; |
| 372 | |
| 373 | const DENSITY: &[SettingOption] = &[ |
| 374 | SettingOption::new("compact", "", ""), |
| 375 | SettingOption::new("comfortable", "", ""), |
| 376 | SettingOption::new("spacious", "", ""), |
| 377 | ]; |
| 378 | |
| 379 | const TRANSCRIPT_SPACING: &[SettingOption] = &[ |
| 380 | SettingOption::new("compact", "", ""), |
| 381 | SettingOption::new("spacious", "", ""), |
| 382 | ]; |
| 383 | |
| 384 | const TOOL_COLLAPSE: &[SettingOption] = &[ |
| 385 | SettingOption::new("compact", "", ""), |
| 386 | SettingOption::new("expanded", "", ""), |
| 387 | SettingOption::new("calm", "", ""), |
| 388 | ]; |
| 389 | |
| 390 | const VIM_MODE: &[SettingOption] = &[ |
| 391 | SettingOption::new("normal", "", ""), |
| 392 | SettingOption::new("vim", "", ""), |
| 393 | ]; |
| 394 | |
| 395 | const MENTION_MENU_BEHAVIOR: &[SettingOption] = &[ |
| 396 | SettingOption::new("fuzzy", "", ""), |
| 397 | SettingOption::new("browser", "", ""), |
| 398 | ]; |
| 399 | |
| 400 | const WORK_SURFACE_PLACEMENT: &[SettingOption] = &[ |
| 401 | SettingOption::new( |
| 402 | "top", |
| 403 | "ConfigChoicePlacementTop", |
| 404 | "ConfigChoiceDetailPlacementTop", |
| 405 | ), |
| 406 | SettingOption::new( |
| 407 | "bottom", |
| 408 | "ConfigChoicePlacementBottom", |
| 409 | "ConfigChoiceDetailPlacementBottom", |
| 410 | ), |
| 411 | SettingOption::new( |
| 412 | "left", |
| 413 | "ConfigChoicePlacementLeft", |
| 414 | "ConfigChoiceDetailPlacementLeft", |
| 415 | ), |
| 416 | SettingOption::new( |
| 417 | "right", |
| 418 | "ConfigChoicePlacementRight", |
| 419 | "ConfigChoiceDetailPlacementRight", |
| 420 | ), |
| 421 | SettingOption::new("off", "ConfigValueOff", "ConfigChoiceDetailPlacementOff"), |
| 422 | ]; |
| 423 | |
| 424 | const RAIL_PANEL: &[SettingOption] = &[ |
| 425 | // The dock's own grammar is lowercase nouns, so the panels the classic |
| 426 | // sidebar never named ride on their raw value (`RailPanel::title`). |
| 427 | SettingOption::new( |
| 428 | "tasks", |
| 429 | "ConfigChoiceRailTasks", |
| 430 | "ConfigChoiceDetailRailTasks", |
| 431 | ), |
| 432 | SettingOption::new( |
| 433 | "agents", |
| 434 | "ConfigChoiceRailAgents", |
| 435 | "ConfigChoiceDetailRailAgents", |
| 436 | ), |
| 437 | SettingOption::new("background", "", ""), |
| 438 | SettingOption::new("files", "", ""), |
| 439 | SettingOption::new("notepad", "", ""), |
| 440 | SettingOption::new( |
| 441 | "context", |
| 442 | "ConfigChoiceRailContext", |
| 443 | "ConfigChoiceDetailRailContext", |
| 444 | ), |
| 445 | SettingOption::new("git", "", ""), |
| 446 | SettingOption::new("price", "", ""), |
| 447 | ]; |
| 448 | |
| 449 | /// Rail tab ids. |
| 450 | pub const TAB_APPEARANCE: &str = "appearance"; |
| 451 | pub const TAB_MODELS: &str = "models"; |
| 452 | pub const TAB_WORK: &str = "work"; |
| 453 | pub const TAB_TOOLS: &str = "tools"; |
| 454 | pub const TAB_TRUST: &str = "trust"; |
| 455 | pub const TAB_MOTION: &str = "motion"; |
| 456 | pub const TAB_ADVANCED: &str = "advanced"; |
| 457 | |
| 458 | const fn ui( |
| 459 | tab: &'static str, |
| 460 | group: &'static str, |
| 461 | label: &'static str, |
| 462 | description: &'static str, |
| 463 | ) -> Option<SettingUi> { |
| 464 | Some(SettingUi { |
| 465 | tab, |
| 466 | group, |
| 467 | label, |
| 468 | description, |
| 469 | row: SettingRowKind::Setting, |
| 470 | }) |
| 471 | } |
| 472 | |
| 473 | /// A row that opens another surface rather than editing a value in place. |
| 474 | const fn ui_action( |
| 475 | tab: &'static str, |
| 476 | group: &'static str, |
| 477 | label: &'static str, |
| 478 | description: &'static str, |
| 479 | ) -> Option<SettingUi> { |
| 480 | Some(SettingUi { |
| 481 | tab, |
| 482 | group, |
| 483 | label, |
| 484 | description, |
| 485 | row: SettingRowKind::Action, |
| 486 | }) |
| 487 | } |
| 488 | |
| 489 | /// A read-only receipt row — a managed-policy fact, live route value, or |
| 490 | /// descriptive pointer, never a writable control. |
| 491 | const fn ui_diagnostic( |
| 492 | tab: &'static str, |
| 493 | group: &'static str, |
| 494 | label: &'static str, |
| 495 | description: &'static str, |
| 496 | ) -> Option<SettingUi> { |
| 497 | Some(SettingUi { |
| 498 | tab, |
| 499 | group, |
| 500 | label, |
| 501 | description, |
| 502 | row: SettingRowKind::Diagnostic, |
| 503 | }) |
| 504 | } |
| 505 | |
| 506 | /// A row editable for the running session only; it does not persist through |
| 507 | /// the config store. |
| 508 | const fn ui_session( |
| 509 | tab: &'static str, |
| 510 | group: &'static str, |
| 511 | label: &'static str, |
| 512 | description: &'static str, |
| 513 | ) -> Option<SettingUi> { |
| 514 | Some(SettingUi { |
| 515 | tab, |
| 516 | group, |
| 517 | label, |
| 518 | description, |
| 519 | row: SettingRowKind::Session, |
| 520 | }) |
| 521 | } |
| 522 | |
| 523 | const fn def( |
| 524 | key: &'static str, |
| 525 | kind: SettingKind, |
| 526 | default: &'static str, |
| 527 | ui: Option<SettingUi>, |
| 528 | ) -> SettingDef { |
| 529 | SettingDef { |
| 530 | key, |
| 531 | kind, |
| 532 | default, |
| 533 | ui, |
| 534 | } |
| 535 | } |
| 536 | |
| 537 | /// Every setting the shell knows about, in render order. |
| 538 | pub const SETTINGS_SCHEMA: &[SettingDef] = &[ |
| 539 | // ── appearance ────────────────────────────────────────────────────── |
| 540 | def( |
| 541 | "theme", |
| 542 | SettingKind::String, |
| 543 | DEFAULT_TUI_THEME, |
| 544 | ui( |
| 545 | TAB_APPEARANCE, |
| 546 | "display", |
| 547 | "ConfigLabelTheme", |
| 548 | "ConfigHintTheme", |
| 549 | ), |
| 550 | ), |
| 551 | def( |
| 552 | "locale", |
| 553 | SettingKind::String, |
| 554 | "auto", |
| 555 | ui( |
| 556 | TAB_APPEARANCE, |
| 557 | "display", |
| 558 | "ConfigLabelLocale", |
| 559 | "ConfigHintLocale", |
| 560 | ), |
| 561 | ), |
| 562 | def( |
| 563 | "background_color", |
| 564 | SettingKind::String, |
| 565 | "", |
| 566 | ui( |
| 567 | TAB_APPEARANCE, |
| 568 | "display", |
| 569 | "ConfigLabelBackground", |
| 570 | "ConfigHintBackgroundColor", |
| 571 | ), |
| 572 | ), |
| 573 | // No sentence anywhere justifies this prototype toggle, so it keeps its |
| 574 | // declaration and loses its row. |
| 575 | def( |
| 576 | "focus_texture", |
| 577 | SettingKind::Enum(FOCUS_TEXTURE), |
| 578 | "off", |
| 579 | None, |
| 580 | ), |
| 581 | def( |
| 582 | "pet_mode", |
| 583 | SettingKind::Bool(ON_OFF), |
| 584 | "false", |
| 585 | ui( |
| 586 | TAB_APPEARANCE, |
| 587 | "display", |
| 588 | "ConfigLabelPetMode", |
| 589 | "ConfigHintPetMode", |
| 590 | ), |
| 591 | ), |
| 592 | def( |
| 593 | "whale_name", |
| 594 | SettingKind::String, |
| 595 | "", |
| 596 | ui( |
| 597 | TAB_APPEARANCE, |
| 598 | "display", |
| 599 | "ConfigLabelWhaleName", |
| 600 | "ConfigHintWhaleName", |
| 601 | ), |
| 602 | ), |
| 603 | def( |
| 604 | "whale_color", |
| 605 | SettingKind::String, |
| 606 | "", |
| 607 | ui( |
| 608 | TAB_APPEARANCE, |
| 609 | "display", |
| 610 | "ConfigLabelWhaleColor", |
| 611 | "ConfigHintWhaleColor", |
| 612 | ), |
| 613 | ), |
| 614 | def( |
| 615 | "calm_mode", |
| 616 | SettingKind::Bool(ON_OFF), |
| 617 | "true", |
| 618 | ui( |
| 619 | TAB_APPEARANCE, |
| 620 | "display", |
| 621 | "ConfigLabelCalmMode", |
| 622 | "ConfigHintCalmMode", |
| 623 | ), |
| 624 | ), |
| 625 | def( |
| 626 | "show_thinking", |
| 627 | SettingKind::Bool(SHOW_THINKING), |
| 628 | "true", |
| 629 | ui( |
| 630 | TAB_APPEARANCE, |
| 631 | "display", |
| 632 | "ConfigLabelShowThinking", |
| 633 | "ConfigHintShowThinking", |
| 634 | ), |
| 635 | ), |
| 636 | def( |
| 637 | "thinking_default_expanded", |
| 638 | SettingKind::Bool(ON_OFF), |
| 639 | "false", |
| 640 | ui( |
| 641 | TAB_APPEARANCE, |
| 642 | "display", |
| 643 | "ConfigLabelThinkingDefaultExpanded", |
| 644 | "ConfigHintThinkingDefaultExpanded", |
| 645 | ), |
| 646 | ), |
| 647 | def( |
| 648 | "thinking_preview_lines", |
| 649 | SettingKind::Int, |
| 650 | "2", |
| 651 | ui( |
| 652 | TAB_APPEARANCE, |
| 653 | "display", |
| 654 | "ConfigLabelThinkingPreviewLines", |
| 655 | "ConfigHintThinkingPreviewLines", |
| 656 | ), |
| 657 | ), |
| 658 | def( |
| 659 | "thinking_highlight", |
| 660 | SettingKind::Bool(THINKING_HIGHLIGHT), |
| 661 | "true", |
| 662 | ui( |
| 663 | TAB_APPEARANCE, |
| 664 | "display", |
| 665 | "ConfigLabelThinkingHighlight", |
| 666 | "ConfigHintThinkingHighlight", |
| 667 | ), |
| 668 | ), |
| 669 | def( |
| 670 | "help_expand_groups", |
| 671 | SettingKind::Bool(ON_OFF), |
| 672 | "false", |
| 673 | ui( |
| 674 | TAB_APPEARANCE, |
| 675 | "display", |
| 676 | "ConfigLabelHelpExpandGroups", |
| 677 | "ConfigHintHelpExpandGroups", |
| 678 | ), |
| 679 | ), |
| 680 | def( |
| 681 | "contextual_tips", |
| 682 | SettingKind::Bool(ON_OFF), |
| 683 | "true", |
| 684 | ui( |
| 685 | TAB_APPEARANCE, |
| 686 | "display", |
| 687 | "ConfigLabelContextualTips", |
| 688 | "ConfigHintContextualTips", |
| 689 | ), |
| 690 | ), |
| 691 | def( |
| 692 | "pin_last_prompt", |
| 693 | SettingKind::Bool(ON_OFF), |
| 694 | "true", |
| 695 | ui( |
| 696 | TAB_APPEARANCE, |
| 697 | "display", |
| 698 | "ConfigLabelPinLastPrompt", |
| 699 | "ConfigHintPinLastPrompt", |
| 700 | ), |
| 701 | ), |
| 702 | def( |
| 703 | "show_tool_details", |
| 704 | SettingKind::Bool(ON_OFF), |
| 705 | "false", |
| 706 | ui( |
| 707 | TAB_APPEARANCE, |
| 708 | "display", |
| 709 | "ConfigLabelShowToolDetails", |
| 710 | "ConfigHintBooleanValues", |
| 711 | ), |
| 712 | ), |
| 713 | def( |
| 714 | "inline_diffs", |
| 715 | SettingKind::Enum(INLINE_DIFFS), |
| 716 | "full", |
| 717 | ui( |
| 718 | TAB_APPEARANCE, |
| 719 | "display", |
| 720 | "ConfigLabelInlineDiffs", |
| 721 | "ConfigHintInlineDiffs", |
| 722 | ), |
| 723 | ), |
| 724 | // No sentence: the glyph set is discoverable from the row's own values. |
| 725 | def( |
| 726 | "status_indicator", |
| 727 | SettingKind::Enum(STATUS_INDICATOR), |
| 728 | "cw", |
| 729 | None, |
| 730 | ), |
| 731 | def( |
| 732 | "synchronized_output", |
| 733 | SettingKind::Enum(SYNCHRONIZED_OUTPUT), |
| 734 | "auto", |
| 735 | ui( |
| 736 | TAB_APPEARANCE, |
| 737 | "display", |
| 738 | "ConfigLabelSynchronizedOutput", |
| 739 | "ConfigHintSynchronizedOutput", |
| 740 | ), |
| 741 | ), |
| 742 | def( |
| 743 | "cost_currency", |
| 744 | SettingKind::Enum(COST_CURRENCY), |
| 745 | "usd", |
| 746 | ui( |
| 747 | TAB_APPEARANCE, |
| 748 | "display", |
| 749 | "ConfigLabelCostCurrency", |
| 750 | "ConfigHintCostCurrency", |
| 751 | ), |
| 752 | ), |
| 753 | def( |
| 754 | "transcript_spacing", |
| 755 | SettingKind::Enum(TRANSCRIPT_SPACING), |
| 756 | "spacious", |
| 757 | ui( |
| 758 | TAB_APPEARANCE, |
| 759 | "display", |
| 760 | "ConfigLabelTranscriptSpacing", |
| 761 | "ConfigHintTranscriptSpacing", |
| 762 | ), |
| 763 | ), |
| 764 | def( |
| 765 | "tool_collapse", |
| 766 | SettingKind::Enum(TOOL_COLLAPSE), |
| 767 | "compact", |
| 768 | ui( |
| 769 | TAB_APPEARANCE, |
| 770 | "display", |
| 771 | "ConfigLabelToolCollapse", |
| 772 | "ConfigHintToolCollapse", |
| 773 | ), |
| 774 | ), |
| 775 | def( |
| 776 | "low_motion", |
| 777 | SettingKind::Bool(LOW_MOTION), |
| 778 | "false", |
| 779 | ui( |
| 780 | TAB_APPEARANCE, |
| 781 | "motion", |
| 782 | "ConfigLabelLowMotion", |
| 783 | "ConfigHintLowMotion", |
| 784 | ), |
| 785 | ), |
| 786 | def( |
| 787 | "fancy_animations", |
| 788 | SettingKind::Bool(FANCY_ANIMATIONS), |
| 789 | "true", |
| 790 | ui( |
| 791 | TAB_APPEARANCE, |
| 792 | "motion", |
| 793 | "ConfigLabelFancyAnimations", |
| 794 | "ConfigHintFancyAnimations", |
| 795 | ), |
| 796 | ), |
| 797 | // ── models & providers ────────────────────────────────────────────── |
| 798 | def( |
| 799 | "provider", |
| 800 | SettingKind::String, |
| 801 | "", |
| 802 | ui_action( |
| 803 | TAB_MODELS, |
| 804 | "provider", |
| 805 | "ConfigLabelProvider", |
| 806 | "ConfigHintProvider", |
| 807 | ), |
| 808 | ), |
| 809 | def( |
| 810 | "model", |
| 811 | SettingKind::String, |
| 812 | "", |
| 813 | ui_action(TAB_MODELS, "model", "ConfigLabelModel", "ConfigHintModel"), |
| 814 | ), |
| 815 | def( |
| 816 | "reasoning_effort", |
| 817 | SettingKind::Enum(REASONING_EFFORT), |
| 818 | "", |
| 819 | ui( |
| 820 | TAB_MODELS, |
| 821 | "model", |
| 822 | "ConfigLabelReasoningEffort", |
| 823 | "ConfigHintReasoningEffort", |
| 824 | ), |
| 825 | ), |
| 826 | // Sub-agent fan-out depth, next to the model rows that drive it. Fleet |
| 827 | // membership itself lives in the /fleet menu, so a one-row Fleet tab |
| 828 | // would only restate this table. |
| 829 | def( |
| 830 | "fleet.exec.max_spawn_depth", |
| 831 | SettingKind::Int, |
| 832 | "3", |
| 833 | ui_diagnostic( |
| 834 | TAB_MODELS, |
| 835 | "model", |
| 836 | "ConfigLabelFleetSpawnDepth", |
| 837 | "ConfigHintFleetMaxSpawnDepth", |
| 838 | ), |
| 839 | ), |
| 840 | // ── work ──────────────────────────────────────────────────────────── |
| 841 | def( |
| 842 | "composer_density", |
| 843 | SettingKind::Enum(DENSITY), |
| 844 | "comfortable", |
| 845 | ui( |
| 846 | TAB_WORK, |
| 847 | "composer", |
| 848 | "ConfigLabelComposerDensity", |
| 849 | "ConfigHintDensity", |
| 850 | ), |
| 851 | ), |
| 852 | def( |
| 853 | "composer_border", |
| 854 | SettingKind::Bool(ON_OFF), |
| 855 | "true", |
| 856 | ui( |
| 857 | TAB_WORK, |
| 858 | "composer", |
| 859 | "ConfigLabelComposerBorder", |
| 860 | "ConfigHintBooleanValues", |
| 861 | ), |
| 862 | ), |
| 863 | def( |
| 864 | "composer_multiline_mode", |
| 865 | SettingKind::Bool(ON_OFF), |
| 866 | "false", |
| 867 | ui( |
| 868 | TAB_WORK, |
| 869 | "composer", |
| 870 | "ConfigLabelComposerMultilineMode", |
| 871 | "ConfigHintComposerMultilineMode", |
| 872 | ), |
| 873 | ), |
| 874 | // Settable via `/set`, surfaced through the composer keymap rather than a |
| 875 | // settings row. |
| 876 | def( |
| 877 | "composer_vim_mode", |
| 878 | SettingKind::Enum(VIM_MODE), |
| 879 | "normal", |
| 880 | None, |
| 881 | ), |
| 882 | // Terminal protocol toggle; available through `/set` but not given a row. |
| 883 | def("bracketed_paste", SettingKind::Bool(ON_OFF), "true", None), |
| 884 | def( |
| 885 | "paste_burst_detection", |
| 886 | SettingKind::Bool(ON_OFF), |
| 887 | "true", |
| 888 | ui( |
| 889 | TAB_WORK, |
| 890 | "composer", |
| 891 | "ConfigLabelPasteBurstDetection", |
| 892 | "ConfigHintBooleanValues", |
| 893 | ), |
| 894 | ), |
| 895 | // Mention-completion tuning knobs; exposed via `/set`, not the settings row. |
| 896 | def("mention_menu_limit", SettingKind::Int, "128", None), |
| 897 | def( |
| 898 | "mention_menu_behavior", |
| 899 | SettingKind::Enum(MENTION_MENU_BEHAVIOR), |
| 900 | "fuzzy", |
| 901 | None, |
| 902 | ), |
| 903 | def("mention_walk_depth", SettingKind::Int, "10", None), |
| 904 | // Workspace discovery option for symlinked layouts; advanced, `/set`-only. |
| 905 | def( |
| 906 | "workspace_follow_symlinks", |
| 907 | SettingKind::Bool(ON_OFF), |
| 908 | "false", |
| 909 | None, |
| 910 | ), |
| 911 | def( |
| 912 | "work_surface_placement", |
| 913 | SettingKind::Enum(WORK_SURFACE_PLACEMENT), |
| 914 | "bottom", |
| 915 | ui( |
| 916 | TAB_WORK, |
| 917 | "workbar", |
| 918 | "ConfigLabelWorkSurfacePlacement", |
| 919 | "ConfigHintWorkSurfacePlacement", |
| 920 | ), |
| 921 | ), |
| 922 | def( |
| 923 | "work_surface_top_height", |
| 924 | SettingKind::Int, |
| 925 | "8", |
| 926 | ui( |
| 927 | TAB_WORK, |
| 928 | "workbar", |
| 929 | "ConfigLabelTopHeight", |
| 930 | "ConfigHintWorkSurfaceTopHeight", |
| 931 | ), |
| 932 | ), |
| 933 | def( |
| 934 | "work_surface_side_width", |
| 935 | SettingKind::Int, |
| 936 | "30", |
| 937 | ui( |
| 938 | TAB_WORK, |
| 939 | "workbar", |
| 940 | "ConfigLabelSideWidth", |
| 941 | "ConfigHintWorkSurfaceSideWidth", |
| 942 | ), |
| 943 | ), |
| 944 | def( |
| 945 | "rail_panel", |
| 946 | SettingKind::Enum(RAIL_PANEL), |
| 947 | "tasks", |
| 948 | ui( |
| 949 | TAB_WORK, |
| 950 | "workbar", |
| 951 | "ConfigLabelRailPanel", |
| 952 | "ConfigHintRailPanel", |
| 953 | ), |
| 954 | ), |
| 955 | // Sidebar panel toggles; driven by view actions and startup flags, not rows. |
| 956 | def("context_panel", SettingKind::Bool(ON_OFF), "false", None), |
| 957 | def("sessions_rail", SettingKind::Bool(ON_OFF), "false", None), |
| 958 | def( |
| 959 | "session_auto_resume", |
| 960 | SettingKind::Bool(ON_OFF), |
| 961 | "false", |
| 962 | None, |
| 963 | ), |
| 964 | def( |
| 965 | "auto_compact", |
| 966 | SettingKind::Bool(ON_OFF), |
| 967 | "false", |
| 968 | ui( |
| 969 | TAB_WORK, |
| 970 | "history", |
| 971 | "ConfigLabelAutoCompact", |
| 972 | "ConfigHintBooleanValues", |
| 973 | ), |
| 974 | ), |
| 975 | def( |
| 976 | "auto_compact_threshold_percent", |
| 977 | SettingKind::Float, |
| 978 | "80", |
| 979 | ui( |
| 980 | TAB_WORK, |
| 981 | "history", |
| 982 | "ConfigLabelAutoCompactThreshold", |
| 983 | "ConfigHintAutoCompactThreshold", |
| 984 | ), |
| 985 | ), |
| 986 | // A computed receipt from auto_compact + threshold; no user-facing row. |
| 987 | def("effective_auto_compact", SettingKind::String, "", None), |
| 988 | def( |
| 989 | "max_history", |
| 990 | SettingKind::Int, |
| 991 | "100", |
| 992 | ui( |
| 993 | TAB_WORK, |
| 994 | "history", |
| 995 | "ConfigLabelMaxHistory", |
| 996 | "ConfigHintMaxHistory", |
| 997 | ), |
| 998 | ), |
| 999 | def( |
| 1000 | "goal_command", |
| 1001 | SettingKind::String, |
| 1002 | "", |
| 1003 | ui_diagnostic( |
| 1004 | TAB_WORK, |
| 1005 | "session", |
| 1006 | "ConfigLabelGoalCommand", |
| 1007 | "ConfigHintGoalCommand", |
| 1008 | ), |
| 1009 | ), |
| 1010 | def( |
| 1011 | "workflow", |
| 1012 | SettingKind::String, |
| 1013 | "", |
| 1014 | ui_diagnostic( |
| 1015 | TAB_WORK, |
| 1016 | "workflow", |
| 1017 | "ConfigLabelWorkflow", |
| 1018 | "ConfigHintWorkflow", |
| 1019 | ), |
| 1020 | ), |
| 1021 | def( |
| 1022 | "notifications.quiet", |
| 1023 | SettingKind::Bool(ON_OFF), |
| 1024 | "false", |
| 1025 | ui( |
| 1026 | TAB_WORK, |
| 1027 | "workflow", |
| 1028 | "ConfigLabelNotificationQuiet", |
| 1029 | "ConfigHintNotificationPolicy", |
| 1030 | ), |
| 1031 | ), |
| 1032 | def( |
| 1033 | "notifications.sound", |
| 1034 | SettingKind::Enum(NOTIFICATION_SOUNDS), |
| 1035 | "legacy", |
| 1036 | ui( |
| 1037 | TAB_WORK, |
| 1038 | "workflow", |
| 1039 | "ConfigLabelNotificationSound", |
| 1040 | "ConfigHintNotificationSound", |
| 1041 | ), |
| 1042 | ), |
| 1043 | def( |
| 1044 | "notifications.condition", |
| 1045 | SettingKind::Enum(NOTIFICATION_CONDITIONS), |
| 1046 | "unfocused", |
| 1047 | ui( |
| 1048 | TAB_WORK, |
| 1049 | "workflow", |
| 1050 | "ConfigLabelNotificationCondition", |
| 1051 | "ConfigHintNotificationPolicy", |
| 1052 | ), |
| 1053 | ), |
| 1054 | def( |
| 1055 | "notifications.method", |
| 1056 | SettingKind::Enum(NOTIFICATION_METHODS), |
| 1057 | "auto", |
| 1058 | ui( |
| 1059 | TAB_WORK, |
| 1060 | "workflow", |
| 1061 | "ConfigLabelNotificationMethod", |
| 1062 | "ConfigHintNotificationPolicy", |
| 1063 | ), |
| 1064 | ), |
| 1065 | def( |
| 1066 | "notifications.threshold_secs", |
| 1067 | SettingKind::Int, |
| 1068 | "30", |
| 1069 | ui( |
| 1070 | TAB_WORK, |
| 1071 | "workflow", |
| 1072 | "ConfigLabelNotificationThreshold", |
| 1073 | "ConfigHintNotificationPolicy", |
| 1074 | ), |
| 1075 | ), |
| 1076 | def( |
| 1077 | "notifications.include_summary", |
| 1078 | SettingKind::Bool(ON_OFF), |
| 1079 | "false", |
| 1080 | ui( |
| 1081 | TAB_WORK, |
| 1082 | "workflow", |
| 1083 | "ConfigLabelNotificationSummary", |
| 1084 | "ConfigHintNotificationPolicy", |
| 1085 | ), |
| 1086 | ), |
| 1087 | def( |
| 1088 | "notifications.subagent_completion", |
| 1089 | SettingKind::Enum(NOTIFICATION_SUBAGENTS), |
| 1090 | "final-only", |
| 1091 | ui( |
| 1092 | TAB_WORK, |
| 1093 | "workflow", |
| 1094 | "ConfigLabelNotificationSubagents", |
| 1095 | "ConfigHintNotificationPolicy", |
| 1096 | ), |
| 1097 | ), |
| 1098 | def( |
| 1099 | "notifications.events.turn-complete", |
| 1100 | SettingKind::Bool(ON_OFF), |
| 1101 | "true", |
| 1102 | ui( |
| 1103 | TAB_WORK, |
| 1104 | "workflow", |
| 1105 | "ConfigLabelNotificationTurnComplete", |
| 1106 | "ConfigHintNotificationPolicy", |
| 1107 | ), |
| 1108 | ), |
| 1109 | def( |
| 1110 | "notifications.events.subagent-terminal", |
| 1111 | SettingKind::Bool(ON_OFF), |
| 1112 | "true", |
| 1113 | ui( |
| 1114 | TAB_WORK, |
| 1115 | "workflow", |
| 1116 | "ConfigLabelNotificationSubagentTerminal", |
| 1117 | "ConfigHintNotificationPolicy", |
| 1118 | ), |
| 1119 | ), |
| 1120 | def( |
| 1121 | "notifications.events.approval-needed", |
| 1122 | SettingKind::Bool(ON_OFF), |
| 1123 | "true", |
| 1124 | ui( |
| 1125 | TAB_WORK, |
| 1126 | "workflow", |
| 1127 | "ConfigLabelNotificationApprovalNeeded", |
| 1128 | "ConfigHintNotificationPolicy", |
| 1129 | ), |
| 1130 | ), |
| 1131 | def( |
| 1132 | "notifications.events.input-needed", |
| 1133 | SettingKind::Bool(ON_OFF), |
| 1134 | "true", |
| 1135 | ui( |
| 1136 | TAB_WORK, |
| 1137 | "workflow", |
| 1138 | "ConfigLabelNotificationInputNeeded", |
| 1139 | "ConfigHintNotificationPolicy", |
| 1140 | ), |
| 1141 | ), |
| 1142 | def( |
| 1143 | "notifications.events.elevation-needed", |
| 1144 | SettingKind::Bool(ON_OFF), |
| 1145 | "true", |
| 1146 | ui( |
| 1147 | TAB_WORK, |
| 1148 | "workflow", |
| 1149 | "ConfigLabelNotificationElevationNeeded", |
| 1150 | "ConfigHintNotificationPolicy", |
| 1151 | ), |
| 1152 | ), |
| 1153 | def( |
| 1154 | "notifications.events.model-notify", |
| 1155 | SettingKind::Bool(ON_OFF), |
| 1156 | "true", |
| 1157 | ui( |
| 1158 | TAB_WORK, |
| 1159 | "workflow", |
| 1160 | "ConfigLabelNotificationModelNotify", |
| 1161 | "ConfigHintNotificationPolicy", |
| 1162 | ), |
| 1163 | ), |
| 1164 | def( |
| 1165 | "notifications.completion_sound", |
| 1166 | SettingKind::Enum(NOTIFICATION_COMPLETION_SOUNDS), |
| 1167 | "off", |
| 1168 | None, |
| 1169 | ), |
| 1170 | def( |
| 1171 | "notifications.sound_file", |
| 1172 | SettingKind::String, |
| 1173 | "", |
| 1174 | ui( |
| 1175 | TAB_WORK, |
| 1176 | "workflow", |
| 1177 | "ConfigLabelNotificationSoundFile", |
| 1178 | "ConfigHintNotificationSound", |
| 1179 | ), |
| 1180 | ), |
| 1181 | def( |
| 1182 | "notifications.event_sound.enabled", |
| 1183 | SettingKind::Bool(ON_OFF), |
| 1184 | "false", |
| 1185 | None, |
| 1186 | ), |
| 1187 | def( |
| 1188 | "notifications.event_sound.events", |
| 1189 | SettingKind::String, |
| 1190 | "[\"turn-complete\", \"approval-needed\"]", |
| 1191 | None, |
| 1192 | ), |
| 1193 | def( |
| 1194 | "notifications.event_sound.min_interval_ms", |
| 1195 | SettingKind::Int, |
| 1196 | "2000", |
| 1197 | ui( |
| 1198 | TAB_WORK, |
| 1199 | "workflow", |
| 1200 | "ConfigLabelNotificationEventSoundInterval", |
| 1201 | "ConfigHintNotificationPolicy", |
| 1202 | ), |
| 1203 | ), |
| 1204 | def( |
| 1205 | "notifications.event_sound.quiet", |
| 1206 | SettingKind::Bool(ON_OFF), |
| 1207 | "false", |
| 1208 | None, |
| 1209 | ), |
| 1210 | // ── tools & MCP ───────────────────────────────────────────────────── |
| 1211 | def( |
| 1212 | "mcp_open", |
| 1213 | SettingKind::String, |
| 1214 | "", |
| 1215 | ui_action(TAB_TOOLS, "mcp", "ConfigLabelMcpOpen", "ConfigHintMcpOpen"), |
| 1216 | ), |
| 1217 | def( |
| 1218 | "mcp_reconnect", |
| 1219 | SettingKind::String, |
| 1220 | "", |
| 1221 | ui_action( |
| 1222 | TAB_TOOLS, |
| 1223 | "mcp", |
| 1224 | "ConfigLabelMcpReconnect", |
| 1225 | "ConfigHintMcpReconnect", |
| 1226 | ), |
| 1227 | ), |
| 1228 | def( |
| 1229 | "mcp_diagnose", |
| 1230 | SettingKind::String, |
| 1231 | "", |
| 1232 | ui_action( |
| 1233 | TAB_TOOLS, |
| 1234 | "mcp", |
| 1235 | "ConfigLabelMcpDiagnose", |
| 1236 | "ConfigHintMcpDiagnose", |
| 1237 | ), |
| 1238 | ), |
| 1239 | def( |
| 1240 | "plugins_open", |
| 1241 | SettingKind::String, |
| 1242 | "", |
| 1243 | ui_action( |
| 1244 | TAB_TOOLS, |
| 1245 | "mcp", |
| 1246 | "ConfigLabelPluginsOpen", |
| 1247 | "ConfigHintPluginsOpen", |
| 1248 | ), |
| 1249 | ), |
| 1250 | def( |
| 1251 | "mcp_config_path", |
| 1252 | SettingKind::String, |
| 1253 | "", |
| 1254 | ui( |
| 1255 | TAB_TOOLS, |
| 1256 | "mcp", |
| 1257 | "ConfigLabelMcpConfigPath", |
| 1258 | "ConfigHintMcpConfigPath", |
| 1259 | ), |
| 1260 | ), |
| 1261 | // ── trust ─────────────────────────────────────────────────────────── |
| 1262 | def( |
| 1263 | "sandbox_details", |
| 1264 | SettingKind::String, |
| 1265 | "", |
| 1266 | ui_action( |
| 1267 | TAB_TRUST, |
| 1268 | "permissions", |
| 1269 | "SetupStepTrustSandboxTitle", |
| 1270 | "SetupStepTrustSandboxWhy", |
| 1271 | ), |
| 1272 | ), |
| 1273 | def( |
| 1274 | "approval_mode", |
| 1275 | SettingKind::Enum(APPROVAL_MODE), |
| 1276 | "", |
| 1277 | ui_session( |
| 1278 | TAB_TRUST, |
| 1279 | "permissions", |
| 1280 | "ConfigLabelApprovalMode", |
| 1281 | "ConfigHintApprovalMode", |
| 1282 | ), |
| 1283 | ), |
| 1284 | def( |
| 1285 | "permission_posture", |
| 1286 | SettingKind::Enum(PERMISSION_POSTURE), |
| 1287 | "accept-edits", |
| 1288 | ui( |
| 1289 | TAB_TRUST, |
| 1290 | "permissions", |
| 1291 | "ConfigLabelPermissionPosture", |
| 1292 | "ConfigHintPermissionPosture", |
| 1293 | ), |
| 1294 | ), |
| 1295 | def( |
| 1296 | "approval_policy", |
| 1297 | SettingKind::Enum(APPROVAL_POLICY), |
| 1298 | "ask", |
| 1299 | ui( |
| 1300 | TAB_TRUST, |
| 1301 | "permissions", |
| 1302 | "ConfigLabelApprovalPolicy", |
| 1303 | "ConfigHintApprovalPolicy", |
| 1304 | ), |
| 1305 | ), |
| 1306 | def( |
| 1307 | "managed_approval_policy", |
| 1308 | SettingKind::String, |
| 1309 | "", |
| 1310 | ui_diagnostic( |
| 1311 | TAB_TRUST, |
| 1312 | "permissions", |
| 1313 | "ConfigLabelManagedApprovalPolicy", |
| 1314 | "ConfigHintManagedApprovalPolicy", |
| 1315 | ), |
| 1316 | ), |
| 1317 | def( |
| 1318 | "default_mode", |
| 1319 | SettingKind::Enum(DEFAULT_MODE), |
| 1320 | "agent", |
| 1321 | ui( |
| 1322 | TAB_TRUST, |
| 1323 | "permissions", |
| 1324 | "ConfigLabelDefaultMode", |
| 1325 | "ConfigHintDefaultMode", |
| 1326 | ), |
| 1327 | ), |
| 1328 | def( |
| 1329 | "allow_shell", |
| 1330 | SettingKind::Bool(ON_OFF), |
| 1331 | "true", |
| 1332 | ui( |
| 1333 | TAB_TRUST, |
| 1334 | "permissions", |
| 1335 | "ConfigLabelAllowShell", |
| 1336 | "ConfigHintAllowShell", |
| 1337 | ), |
| 1338 | ), |
| 1339 | def( |
| 1340 | "managed_allow_shell", |
| 1341 | SettingKind::String, |
| 1342 | "", |
| 1343 | ui_diagnostic( |
| 1344 | TAB_TRUST, |
| 1345 | "permissions", |
| 1346 | "ConfigLabelManagedAllowShell", |
| 1347 | "ConfigHintManagedAllowShell", |
| 1348 | ), |
| 1349 | ), |
| 1350 | def( |
| 1351 | "telemetry", |
| 1352 | SettingKind::Bool(TELEMETRY), |
| 1353 | "true", |
| 1354 | ui( |
| 1355 | TAB_TRUST, |
| 1356 | "network", |
| 1357 | "ConfigLabelTelemetry", |
| 1358 | "ConfigHintTelemetry", |
| 1359 | ), |
| 1360 | ), |
| 1361 | // ── advanced ──────────────────────────────────────────────────────── |
| 1362 | def( |
| 1363 | "base_url", |
| 1364 | SettingKind::String, |
| 1365 | "", |
| 1366 | ui_diagnostic( |
| 1367 | TAB_ADVANCED, |
| 1368 | "provider", |
| 1369 | "ConfigLabelBaseUrlDeepseek", |
| 1370 | "ConfigHintBaseUrl", |
| 1371 | ), |
| 1372 | ), |
| 1373 | def( |
| 1374 | "provider_url", |
| 1375 | SettingKind::String, |
| 1376 | "", |
| 1377 | ui_diagnostic( |
| 1378 | TAB_ADVANCED, |
| 1379 | "provider", |
| 1380 | "ConfigLabelProviderUrl", |
| 1381 | "ConfigHintProviderUrl", |
| 1382 | ), |
| 1383 | ), |
| 1384 | def( |
| 1385 | "context_window", |
| 1386 | SettingKind::Int, |
| 1387 | "", |
| 1388 | ui_diagnostic( |
| 1389 | TAB_ADVANCED, |
| 1390 | "provider", |
| 1391 | "ConfigLabelContextWindow", |
| 1392 | "ConfigHintContextWindow", |
| 1393 | ), |
| 1394 | ), |
| 1395 | def( |
| 1396 | "effective_context_window", |
| 1397 | SettingKind::String, |
| 1398 | "", |
| 1399 | ui_diagnostic( |
| 1400 | TAB_ADVANCED, |
| 1401 | "provider", |
| 1402 | "ConfigLabelEffectiveContextWindow", |
| 1403 | "ConfigHintEffectiveContextWindow", |
| 1404 | ), |
| 1405 | ), |
| 1406 | // Trust receipts: which external credential file a provider may read, and |
| 1407 | // under what access. Read-only here; `/provider` owns changing them. |
| 1408 | def( |
| 1409 | "external_credentials.openai-codex", |
| 1410 | SettingKind::String, |
| 1411 | "", |
| 1412 | ui_diagnostic( |
| 1413 | TAB_ADVANCED, |
| 1414 | "provider", |
| 1415 | "ConfigLabelExternalCredentialsCodex", |
| 1416 | "ConfigHintExternalCredentials", |
| 1417 | ), |
| 1418 | ), |
| 1419 | def( |
| 1420 | "external_credentials.xai", |
| 1421 | SettingKind::String, |
| 1422 | "", |
| 1423 | ui_diagnostic( |
| 1424 | TAB_ADVANCED, |
| 1425 | "provider", |
| 1426 | "ConfigLabelExternalCredentialsXai", |
| 1427 | "ConfigHintExternalCredentials", |
| 1428 | ), |
| 1429 | ), |
| 1430 | // Derived fast-sibling receipt, retired from the table: the /model picker |
| 1431 | // already names the fast sibling where a choice actually happens, and no |
| 1432 | // backend reads `fast_model` as a persisted key. |
| 1433 | def("fast_model", SettingKind::String, "", None), |
| 1434 | // A transport timeout; advanced networking, available through `/set` only. |
| 1435 | def("stream_chunk_timeout_secs", SettingKind::Int, "900", None), |
| 1436 | // Canonical transport keys. Runtime resolution stays in TUI Config. |
| 1437 | def("stream.open_timeout_secs", SettingKind::Int, "180", None), |
| 1438 | def("stream.open_retries", SettingKind::Int, "1", None), |
| 1439 | def( |
| 1440 | "stream.unknown_outcome_retries", |
| 1441 | SettingKind::Int, |
| 1442 | "0", |
| 1443 | None, |
| 1444 | ), |
| 1445 | def("stream.chunk_timeout_secs", SettingKind::Int, "900", None), |
| 1446 | def("stream.max_resumes", SettingKind::Int, "3", None), |
| 1447 | def( |
| 1448 | "stream.max_transparent_retries", |
| 1449 | SettingKind::Int, |
| 1450 | "2", |
| 1451 | None, |
| 1452 | ), |
| 1453 | def("stream.max_stream_errors", SettingKind::Int, "5", None), |
| 1454 | def("stream.max_duration_secs", SettingKind::Int, "1800", None), |
| 1455 | def("stream.max_content_mb", SettingKind::Int, "10", None), |
| 1456 | def("stream.connect_timeout_secs", SettingKind::Int, "30", None), |
| 1457 | def("stream.tcp_keepalive_secs", SettingKind::Int, "30", None), |
| 1458 | def( |
| 1459 | "stream.http2_keep_alive_interval_secs", |
| 1460 | SettingKind::Int, |
| 1461 | "15", |
| 1462 | None, |
| 1463 | ), |
| 1464 | def( |
| 1465 | "stream.http2_keep_alive_timeout_secs", |
| 1466 | SettingKind::Int, |
| 1467 | "20", |
| 1468 | None, |
| 1469 | ), |
| 1470 | def( |
| 1471 | "stream.force_http1", |
| 1472 | SettingKind::Bool(ON_OFF), |
| 1473 | "false", |
| 1474 | None, |
| 1475 | ), |
| 1476 | // DeepSeek-only legacy fallback: the runtime still reads it, but it is |
| 1477 | // not a live choice, so it stays settable through `/set` without a row. |
| 1478 | def("default_model", SettingKind::String, "", None), |
| 1479 | // Beta vision flag: the feature backend stays live, but the row goes — |
| 1480 | // feature state is diagnosed where vision runs, not in Advanced. |
| 1481 | def("features.vision_model", SettingKind::String, "", None), |
| 1482 | def( |
| 1483 | "features.subagents", |
| 1484 | SettingKind::String, |
| 1485 | "", |
| 1486 | ui_diagnostic( |
| 1487 | TAB_ADVANCED, |
| 1488 | "experimental", |
| 1489 | "", |
| 1490 | "ConfigHintFeatureSubagents", |
| 1491 | ), |
| 1492 | ), |
| 1493 | def( |
| 1494 | "features.web_search", |
| 1495 | SettingKind::String, |
| 1496 | "", |
| 1497 | ui_diagnostic( |
| 1498 | TAB_ADVANCED, |
| 1499 | "experimental", |
| 1500 | "", |
| 1501 | "ConfigHintFeatureWebSearch", |
| 1502 | ), |
| 1503 | ), |
| 1504 | def( |
| 1505 | "features.apply_patch", |
| 1506 | SettingKind::String, |
| 1507 | "", |
| 1508 | ui_diagnostic( |
| 1509 | TAB_ADVANCED, |
| 1510 | "experimental", |
| 1511 | "", |
| 1512 | "ConfigHintFeatureApplyPatch", |
| 1513 | ), |
| 1514 | ), |
| 1515 | def( |
| 1516 | "features.mcp", |
| 1517 | SettingKind::String, |
| 1518 | "", |
| 1519 | ui_diagnostic(TAB_ADVANCED, "experimental", "", "ConfigHintFeatureMcp"), |
| 1520 | ), |
| 1521 | def( |
| 1522 | "features.exec_policy", |
| 1523 | SettingKind::String, |
| 1524 | "", |
| 1525 | ui_diagnostic( |
| 1526 | TAB_ADVANCED, |
| 1527 | "experimental", |
| 1528 | "", |
| 1529 | "ConfigHintFeatureExecPolicy", |
| 1530 | ), |
| 1531 | ), |
| 1532 | // ── persisted field names without a row ───────────────────────────── |
| 1533 | // Every field `Settings` serializes to settings.toml has a declaration; |
| 1534 | // these have `ui: None` because their value is owned elsewhere: |
| 1535 | // route pickers, `/set` aliases with their own canonical row, or |
| 1536 | // internal one-way flags. Declaration order is render order, and hidden |
| 1537 | // entries render nothing, so they live together at the end. |
| 1538 | // |
| 1539 | // Canonical names behind a `/set` alias row: `set()` accepts both |
| 1540 | // spellings, the row carries the alias. |
| 1541 | def("tool_collapse_mode", SettingKind::String, "compact", None), |
| 1542 | def("max_input_history", SettingKind::Int, "100", None), |
| 1543 | // Written by the route pickers, not by a settings row (the provider / |
| 1544 | // model rows persist to config.toml via `set_config_value`). |
| 1545 | def("default_provider", SettingKind::String, "", None), |
| 1546 | // Trust posture with a `/set` entry point but no row; surfaced where |
| 1547 | // sandboxing acts, not as a settings sentence. |
| 1548 | def("sandbox_mode", SettingKind::String, "", None), |
| 1549 | def("agents", SettingKind::String, "", None), |
| 1550 | // Route memory written by the pickers: per-provider defaults, enabled |
| 1551 | // chooser sets, and pinned routes. Structured values no row could edit. |
| 1552 | def("provider_models", SettingKind::String, "", None), |
| 1553 | def("enabled_models", SettingKind::String, "", None), |
| 1554 | def("pinned_models", SettingKind::String, "", None), |
| 1555 | // One-way internal flags: shown an intro, shown a deprecation, counted |
| 1556 | // tip impressions. Read back to suppress repeats, never edited. |
| 1557 | def( |
| 1558 | "feature_intro_shown", |
| 1559 | SettingKind::Bool(ON_OFF), |
| 1560 | "false", |
| 1561 | None, |
| 1562 | ), |
| 1563 | def( |
| 1564 | "yolo_deprecation_shown", |
| 1565 | SettingKind::Bool(ON_OFF), |
| 1566 | "false", |
| 1567 | None, |
| 1568 | ), |
| 1569 | def( |
| 1570 | "operate_deprecation_shown", |
| 1571 | SettingKind::Bool(ON_OFF), |
| 1572 | "false", |
| 1573 | None, |
| 1574 | ), |
| 1575 | def( |
| 1576 | "account_preferences_notice_shown", |
| 1577 | SettingKind::String, |
| 1578 | "", |
| 1579 | None, |
| 1580 | ), |
| 1581 | // Round 3 work-bar placement migration ran once (`top` → `bottom`). |
| 1582 | def( |
| 1583 | "work_surface_bottom_migrated", |
| 1584 | SettingKind::Bool(ON_OFF), |
| 1585 | "false", |
| 1586 | None, |
| 1587 | ), |
| 1588 | def("behavioral_tip_impressions", SettingKind::String, "", None), |
| 1589 | // Footer key-hint use counts: a hint retires to its bare state once its |
| 1590 | // binding has been used enough times. Written by the footer, never edited. |
| 1591 | def("footer_hint_uses", SettingKind::String, "", None), |
| 1592 | ]; |
| 1593 | |
| 1594 | /// The declaration for `key`, if the shell knows it. |
| 1595 | pub fn setting(key: &str) -> Option<&'static SettingDef> { |
| 1596 | SETTINGS_SCHEMA.iter().find(|def| def.key == key) |
| 1597 | } |
| 1598 | |
| 1599 | /// Position of `key` in declaration order; `None` for unknown keys. |
| 1600 | pub fn setting_index(key: &str) -> Option<usize> { |
| 1601 | SETTINGS_SCHEMA.iter().position(|def| def.key == key) |
| 1602 | } |
| 1603 | |
| 1604 | /// Distinct `ui.tab` ids, in the order they are first declared. |
| 1605 | pub fn schema_tabs() -> Vec<&'static str> { |
| 1606 | let mut tabs: Vec<&'static str> = Vec::new(); |
| 1607 | for ui in SETTINGS_SCHEMA.iter().filter_map(|def| def.ui.as_ref()) { |
| 1608 | if !tabs.contains(&ui.tab) { |
| 1609 | tabs.push(ui.tab); |
| 1610 | } |
| 1611 | } |
| 1612 | tabs |
| 1613 | } |
| 1614 | |
| 1615 | /// Distinct `ui.group` ids within `tab`, in the order they are first declared. |
| 1616 | pub fn schema_groups(tab: &str) -> Vec<&'static str> { |
| 1617 | let mut groups: Vec<&'static str> = Vec::new(); |
| 1618 | for ui in SETTINGS_SCHEMA |
| 1619 | .iter() |
| 1620 | .filter_map(|def| def.ui.as_ref()) |
| 1621 | .filter(|ui| ui.tab == tab) |
| 1622 | { |
| 1623 | if !groups.contains(&ui.group) { |
| 1624 | groups.push(ui.group); |
| 1625 | } |
| 1626 | } |
| 1627 | groups |
| 1628 | } |
| 1629 | |
| 1630 | /// Settings declared with a row, in declaration order. |
| 1631 | pub fn schema_rows() -> impl Iterator<Item = &'static SettingDef> { |
| 1632 | SETTINGS_SCHEMA.iter().filter(|def| def.ui.is_some()) |
| 1633 | } |
| 1634 | |
| 1635 | #[cfg(test)] |
| 1636 | mod tests { |
| 1637 | use super::*; |
| 1638 | use std::collections::BTreeSet; |
| 1639 | |
| 1640 | #[test] |
| 1641 | fn schema_keys_are_unique() { |
| 1642 | let mut seen = BTreeSet::new(); |
| 1643 | for def in SETTINGS_SCHEMA { |
| 1644 | assert!(seen.insert(def.key), "duplicate setting key: {}", def.key); |
| 1645 | } |
| 1646 | assert_eq!(seen.len(), SETTINGS_SCHEMA.len()); |
| 1647 | } |
| 1648 | |
| 1649 | #[test] |
| 1650 | fn every_row_declares_a_tab_group_and_description() { |
| 1651 | for def in schema_rows() { |
| 1652 | let ui = def.ui.as_ref().expect("schema_rows filters on ui"); |
| 1653 | assert!(!ui.tab.is_empty(), "{} has an empty tab", def.key); |
| 1654 | assert!(!ui.group.is_empty(), "{} has an empty group", def.key); |
| 1655 | if !def.key.starts_with("features.") { |
| 1656 | assert!(!ui.label.is_empty(), "{} has an empty label", def.key); |
| 1657 | } |
| 1658 | assert!( |
| 1659 | !ui.description.is_empty(), |
| 1660 | "{} has a row but no sentence justifying it", |
| 1661 | def.key |
| 1662 | ); |
| 1663 | } |
| 1664 | for key in ["low_motion", "fancy_animations"] { |
| 1665 | let ui = setting(key) |
| 1666 | .and_then(|def| def.ui.as_ref()) |
| 1667 | .expect("motion setting has ui"); |
| 1668 | assert_eq!(ui.tab, TAB_APPEARANCE); |
| 1669 | assert_eq!(ui.group, "motion"); |
| 1670 | } |
| 1671 | for key in [ |
| 1672 | "notifications.completion_sound", |
| 1673 | "notifications.event_sound.enabled", |
| 1674 | "notifications.event_sound.events", |
| 1675 | "notifications.event_sound.quiet", |
| 1676 | ] { |
| 1677 | assert!( |
| 1678 | setting(key).expect("legacy key exists").ui.is_none(), |
| 1679 | "{key} should be hidden from the settings UI" |
| 1680 | ); |
| 1681 | } |
| 1682 | } |
| 1683 | |
| 1684 | #[test] |
| 1685 | fn declaration_order_groups_rows_by_tab_then_group() { |
| 1686 | // The surface renders runs of rows; a tab or group that reappears |
| 1687 | // after another one would paint two headings with the same name. |
| 1688 | let mut seen_tabs: Vec<&str> = Vec::new(); |
| 1689 | let mut seen_pairs: Vec<(&str, &str)> = Vec::new(); |
| 1690 | let mut current: Option<(&str, &str)> = None; |
| 1691 | for def in schema_rows() { |
| 1692 | let ui = def.ui.as_ref().expect("row"); |
| 1693 | if current.map(|(tab, _)| tab) != Some(ui.tab) { |
| 1694 | assert!(!seen_tabs.contains(&ui.tab), "tab {} is split", ui.tab); |
| 1695 | seen_tabs.push(ui.tab); |
| 1696 | } |
| 1697 | if current != Some((ui.tab, ui.group)) { |
| 1698 | assert!( |
| 1699 | !seen_pairs.contains(&(ui.tab, ui.group)), |
| 1700 | "group {}/{} is split", |
| 1701 | ui.tab, |
| 1702 | ui.group |
| 1703 | ); |
| 1704 | seen_pairs.push((ui.tab, ui.group)); |
| 1705 | } |
| 1706 | current = Some((ui.tab, ui.group)); |
| 1707 | } |
| 1708 | assert_eq!(schema_tabs(), seen_tabs); |
| 1709 | } |
| 1710 | |
| 1711 | #[test] |
| 1712 | fn enum_values_are_unique_and_defaults_are_declared_values() { |
| 1713 | for def in SETTINGS_SCHEMA { |
| 1714 | if let Some(values) = def.values() { |
| 1715 | let unique: BTreeSet<_> = values.iter().collect(); |
| 1716 | assert_eq!(unique.len(), values.len(), "{} repeats a value", def.key); |
| 1717 | if !def.default.is_empty() { |
| 1718 | assert!( |
| 1719 | values.contains(&def.default), |
| 1720 | "{} defaults to {} which is not one of its values", |
| 1721 | def.key, |
| 1722 | def.default |
| 1723 | ); |
| 1724 | } |
| 1725 | } |
| 1726 | } |
| 1727 | } |
| 1728 | } |
| 1729 |