feat: expose prompt caching TTL setting in UI (#273)

Adds a dropdown to select ENABLE_PROMPT_CACHING_1H or FORCE_PROMPT_CACHING_5M env vars when starting Claude Code sessions. Requires Claude Code v2.1.108+.
This commit is contained in:
2026-05-06 14:01:00 -07:00
committed by Naomi Carrigan
parent 3f57937d54
commit 38692391e0
12 changed files with 67 additions and 0 deletions
+12
View File
@@ -75,6 +75,11 @@ pub struct ClaudeStartOptions {
/// Valid values: "low", "medium", "high", "xhigh" (Opus 4.7 only), "max". None uses CLI default.
#[serde(default)]
pub effort_level: Option<String>,
/// Sets `ENABLE_PROMPT_CACHING_1H=1` or `FORCE_PROMPT_CACHING_5M=1` env var (v2.1.108+).
/// Values: "1h" → 1-hour TTL, "5m" → force 5-minute TTL. None uses CLI default.
#[serde(default)]
pub prompt_caching_ttl: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -246,6 +251,11 @@ pub struct HikariConfig {
/// Valid values: "low", "medium", "high", "xhigh" (Opus 4.7 only), "max". None uses CLI default.
#[serde(default)]
pub effort_level: Option<String>,
/// Sets `ENABLE_PROMPT_CACHING_1H=1` or `FORCE_PROMPT_CACHING_5M=1` env var (v2.1.108+).
/// Values: "1h" → 1-hour TTL, "5m" → force 5-minute TTL. None uses CLI default.
#[serde(default)]
pub prompt_caching_ttl: Option<String>,
}
impl Default for HikariConfig {
@@ -302,6 +312,7 @@ impl Default for HikariConfig {
show_clear_context_on_plan_accept: true,
custom_model_option: None,
effort_level: None,
prompt_caching_ttl: None,
}
}
}
@@ -520,6 +531,7 @@ mod tests {
show_clear_context_on_plan_accept: true,
custom_model_option: None,
effort_level: None,
prompt_caching_ttl: None,
};
let json = serde_json::to_string(&config).unwrap();
+18
View File
@@ -410,6 +410,15 @@ impl WslBridge {
}
}
// Set prompt caching TTL env var if specified (v2.1.108+)
if let Some(ref ttl) = options.prompt_caching_ttl {
match ttl.as_str() {
"1h" => { cmd.env("ENABLE_PROMPT_CACHING_1H", "1"); }
"5m" => { cmd.env("FORCE_PROMPT_CACHING_5M", "1"); }
_ => {}
}
}
cmd
} else {
// Running on Windows - use wsl with bash login shell to ensure PATH is loaded
@@ -485,6 +494,15 @@ impl WslBridge {
}
}
// Set prompt caching TTL env var if specified (v2.1.108+)
if let Some(ref ttl) = options.prompt_caching_ttl {
match ttl.as_str() {
"1h" => { claude_cmd.push_str("ENABLE_PROMPT_CACHING_1H=1 "); }
"5m" => { claude_cmd.push_str("FORCE_PROMPT_CACHING_5M=1 "); }
_ => {}
}
}
claude_cmd.push_str(
"claude --output-format stream-json --input-format stream-json --verbose",
);