feat(quick-pane): persist default thinking level
This commit is contained in:
@@ -12,6 +12,7 @@ const MAX_DRAFT_BYTES: usize = 128 * 1024;
|
||||
const MAX_TOTAL_DRAFT_BYTES: usize = 1024 * 1024;
|
||||
const MAX_TOTAL_STRING_BYTES: usize = 1536 * 1024;
|
||||
const MAX_FILE_BYTES: usize = 2 * 1024 * 1024;
|
||||
const DEFAULT_THINKING_LEVEL: &str = "medium";
|
||||
|
||||
#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
@@ -47,6 +48,12 @@ pub struct QuickPaneSettings {
|
||||
pub follow_up_model: String,
|
||||
pub instructions: String,
|
||||
pub maximum_tool_calls: u32,
|
||||
#[serde(default = "default_thinking_level")]
|
||||
pub default_thinking_level: String,
|
||||
}
|
||||
|
||||
fn default_thinking_level() -> String {
|
||||
DEFAULT_THINKING_LEVEL.to_owned()
|
||||
}
|
||||
|
||||
impl Default for QuickPaneSettings {
|
||||
@@ -59,6 +66,7 @@ impl Default for QuickPaneSettings {
|
||||
follow_up_model: String::new(),
|
||||
instructions: "Answer quickly. Do not use subagents. Prefer read-only inspection. Escalate mutations, multi-step work, or complex work.".to_owned(),
|
||||
maximum_tool_calls: 6,
|
||||
default_thinking_level: default_thinking_level(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -233,6 +241,12 @@ pub fn validate(state: &UiStateV1) -> Result<(), String> {
|
||||
if !(1..=64).contains(&quick.maximum_tool_calls) {
|
||||
return Err("Quick-pane tool-call limit is outside the supported range".to_owned());
|
||||
}
|
||||
if !matches!(
|
||||
quick.default_thinking_level.as_str(),
|
||||
"off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max"
|
||||
) {
|
||||
return Err("Quick-pane default thinking level is invalid".to_owned());
|
||||
}
|
||||
total_string_bytes = total_string_bytes
|
||||
.saturating_add(quick.workspace.len())
|
||||
.saturating_add(quick.provider.len())
|
||||
@@ -449,6 +463,12 @@ mod tests {
|
||||
state.quick_pane.follow_up_provider = "provider".into();
|
||||
state.quick_pane.follow_up_model = "follow-up-model".into();
|
||||
assert!(validate(&state).is_ok());
|
||||
state.quick_pane.default_thinking_level = "high".into();
|
||||
save_to(&root, &state).unwrap();
|
||||
assert_eq!(load_from(&root).unwrap().quick_pane.default_thinking_level, "high");
|
||||
state.quick_pane.default_thinking_level = "unsupported".into();
|
||||
assert!(validate(&state).is_err());
|
||||
state.quick_pane.default_thinking_level = default_thinking_level();
|
||||
state.quick_pane.maximum_tool_calls = 0;
|
||||
assert!(validate(&state).is_err());
|
||||
fs::remove_dir_all(root).unwrap();
|
||||
@@ -465,8 +485,11 @@ mod tests {
|
||||
)
|
||||
.unwrap();
|
||||
let state = load_from(&root).unwrap();
|
||||
assert_eq!(state.quick_pane.default_thinking_level, DEFAULT_THINKING_LEVEL);
|
||||
save_to(&root, &state).unwrap();
|
||||
assert!(!fs::read_to_string(&path).unwrap().contains("maximumSeconds"));
|
||||
let saved = fs::read_to_string(&path).unwrap();
|
||||
assert!(!saved.contains("maximumSeconds"));
|
||||
assert!(saved.contains("\"defaultThinkingLevel\": \"medium\""));
|
||||
fs::remove_dir_all(root).unwrap();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user