Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

feat(agent): standalone provider config without Desktop (#232)

Akarshan Biswasf977e66013e1
diff --git a/src-tauri/src/bin/jan.rs b/src-tauri/src/bin/jan.rs
index d4427bc11..e663bb506 100644
--- a/src-tauri/src/bin/jan.rs
+++ b/src-tauri/src/bin/jan.rs
@@ -14,6 +14,7 @@ use indicatif::{ProgressBar, ProgressStyle};
// The lib target is named "app_lib" (see [lib] section in Cargo.toml).
use app_lib::core::cli::providers::ProviderOverrides;
use app_lib::core::cli::{
+ cli_agent_config_list, cli_agent_config_path, cli_agent_config_set, cli_agent_config_unset,
cli_agent_run, cli_agent_status, cli_agent_step, cli_agent_ui, cli_delete_thread,
cli_get_data_folder, cli_get_thread, cli_list_messages, cli_list_threads,
discover_llamacpp_binary, download_hf_model, ensure_router_and_load, fetch_hf_gguf_files,
@@ -216,6 +217,46 @@ enum AgentCommands {
#[command(flatten)]
providers: ProviderArgs,
},
+ /// Manage standalone provider credentials in ~/.jan/config.toml (no Desktop needed)
+ Config {
+ #[command(subcommand)]
+ cmd: AgentConfigCommands,
+ },
+}
+
+/// Read/write the user-wide `~/.jan/config.toml` provider store. This is the
+/// self-sufficient config surface for a standalone Jan Agent: every command is
+/// headless and persists across runs.
+#[derive(Subcommand)]
+enum AgentConfigCommands {
+ /// Set or update a provider's API key, base URL, models, or API type
+ Set {
+ /// Provider id (e.g. openai, anthropic, groq)
+ #[arg(long)]
+ provider: String,
+ /// API key for the provider
+ #[arg(long)]
+ api_key: Option<String>,
+ /// Base URL (e.g. https://api.openai.com/v1)
+ #[arg(long)]
+ base_url: Option<String>,
+ /// Model id to expose (repeatable; replaces any existing list)
+ #[arg(long = "model")]
+ models: Vec<String>,
+ /// Wire API type (e.g. openai, anthropic); defaults to OpenAI-compatible
+ #[arg(long)]
+ api_type: Option<String>,
+ },
+ /// Remove a provider entry
+ Unset {
+ /// Provider id to remove
+ #[arg(long)]
+ provider: String,
+ },
+ /// List configured providers as JSON (API keys redacted)
+ List,
+ /// Print the config file path (scaffolding a template if absent)
+ Path,
}
// ── Threads subcommands ────────────────────────────────────────────────────
@@ -504,6 +545,7 @@ async fn handle_agent(cmd: AgentCommands) {
Err(e) => Err(e),
}
}
+ AgentCommands::Config { cmd } => handle_agent_config(cmd),
};
if let Err(e) = result {
eprintln!("Error: {e}");
@@ -511,6 +553,41 @@ async fn handle_agent(cmd: AgentCommands) {
}
}
+fn handle_agent_config(cmd: AgentConfigCommands) -> Result<(), String> {
+ match cmd {
+ AgentConfigCommands::Set {
+ provider,
+ api_key,
+ base_url,
+ models,
+ api_type,
+ } => {
+ let models = (!models.is_empty()).then_some(models);
+ let path = cli_agent_config_set(&provider, api_key, base_url, models, api_type)?;
+ println!("Updated provider '{provider}' in {}", path.display());
+ Ok(())
+ }
+ AgentConfigCommands::Unset { provider } => {
+ if cli_agent_config_unset(&provider)? {
+ println!("Removed provider '{provider}'");
+ } else {
+ println!("Provider '{provider}' was not configured");
+ }
+ Ok(())
+ }
+ AgentConfigCommands::List => {
+ let list = cli_agent_config_list()?;
+ println!("{}", serde_json::to_string_pretty(&list).unwrap());
+ Ok(())
+ }
+ AgentConfigCommands::Path => {
+ let path = cli_agent_config_path()?;
+ println!("{}", path.display());
+ Ok(())
+ }
+ }
+}
+
// ── Threads handlers ───────────────────────────────────────────────────────
async fn handle_threads(cmd: ThreadsCommands) {
diff --git a/src-tauri/src/core/agent/global_config.rs b/src-tauri/src/core/agent/global_config.rs
index 6e4988290..52f5c0056 100644
--- a/src-tauri/src/core/agent/global_config.rs
+++ b/src-tauri/src/core/agent/global_config.rs
@@ -6,7 +6,7 @@
use std::collections::HashMap;
use std::path::PathBuf;
-use serde::Deserialize;
+use serde::{Deserialize, Serialize};
use crate::core::state::ProviderConfig;
@@ -14,6 +14,8 @@ const GLOBAL_CONFIG_TEMPLATE: &str = r#"# Jan Agent global provider config.
# Applies to every project unless overridden by that project's
# .jan/agent/agent.toml [provider] section.
#
+# default_model = "gpt-4o" # used when no --model / agent.toml model is set
+#
# [providers.openai]
# api_key = "sk-..."
# base_url = "https://api.openai.com/v1"
@@ -24,24 +26,39 @@ const GLOBAL_CONFIG_TEMPLATE: &str = r#"# Jan Agent global provider config.
# models = ["claude-sonnet-5"]
"#;
-#[derive(Debug, Clone, Default, Deserialize)]
+#[derive(Debug, Clone, Default, Deserialize, Serialize)]
struct GlobalConfigToml {
+ /// Explicit default model for a standalone agent, used when neither a CLI
+ /// flag nor `agent.toml` names one. Takes precedence over any derived guess.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ default_model: Option<String>,
#[serde(default)]
providers: HashMap<String, GlobalProviderEntry>,
}
-#[derive(Debug, Clone, Default, Deserialize)]
+#[derive(Debug, Clone, Default, Deserialize, Serialize)]
struct GlobalProviderEntry {
- #[serde(default)]
+ #[serde(default, skip_serializing_if = "Option::is_none")]
api_key: Option<String>,
- #[serde(default)]
+ #[serde(default, skip_serializing_if = "Option::is_none")]
base_url: Option<String>,
- #[serde(default)]
+ #[serde(default, skip_serializing_if = "Vec::is_empty")]
models: Vec<String>,
- #[serde(default)]
+ #[serde(default, skip_serializing_if = "Option::is_none")]
api_type: Option<String>,
}
+/// Fields to update on a provider entry via [`set_provider`]. `None` leaves the
+/// existing value untouched (merge semantics); `Some` overwrites it.
+#[derive(Debug, Default, Clone)]
+pub(crate) struct ProviderUpdate {
+ pub api_key: Option<String>,
+ pub base_url: Option<String>,
+ /// `Some(vec)` replaces the model list; `Some(empty)` clears it.
+ pub models: Option<Vec<String>>,
+ pub api_type: Option<String>,
+}
+
/// `~/.jan`, the user-wide config directory.
pub(crate) fn global_jan_dir() -> Result<PathBuf, String> {
dirs::home_dir()
@@ -89,6 +106,92 @@ pub(crate) fn load_global_config() -> Result<HashMap<String, ProviderConfig>, St
.collect())
}
+/// Resolve a default model from `~/.jan/config.toml` for a standalone agent:
+/// the explicit `default_model` key if set, else the first model of the first
+/// provider (providers sorted by name for determinism). `None` when nothing is
+/// configured. Errors only on a malformed file.
+pub(crate) fn default_model() -> Result<Option<String>, String> {
+ let config = load_raw()?;
+ if let Some(model) = config.default_model.filter(|m| !m.trim().is_empty()) {
+ return Ok(Some(model));
+ }
+ let mut providers: Vec<_> = config.providers.into_iter().collect();
+ providers.sort_by(|a, b| a.0.cmp(&b.0));
+ Ok(providers
+ .into_iter()
+ .find_map(|(_, entry)| entry.models.into_iter().next()))
+}
+
+/// Read `~/.jan/config.toml` into the raw TOML struct for editing. Missing file
+/// -> default (empty); malformed file -> error, so a set never silently drops an
+/// unparseable file's contents.
+fn load_raw() -> Result<GlobalConfigToml, String> {
+ let path = global_config_path()?;
+ let raw = match std::fs::read_to_string(&path) {
+ Ok(raw) => raw,
+ Err(_) => return Ok(GlobalConfigToml::default()),
+ };
+ toml::from_str(&raw).map_err(|e| format!("Failed to parse {}: {e}", path.display()))
+}
+
+/// Serialize the config back to `~/.jan/config.toml`, creating `~/.jan` if
+/// needed. The directory is user-scoped; the file is world-unreadable on Unix
+/// since it holds API keys.
+fn write_raw(config: &GlobalConfigToml) -> Result<PathBuf, String> {
+ let dir = global_jan_dir()?;
+ std::fs::create_dir_all(&dir).map_err(|e| format!("Failed to create {}: {e}", dir.display()))?;
+ let path = dir.join("config.toml");
+ let body = toml::to_string_pretty(config).map_err(|e| format!("Failed to serialize config: {e}"))?;
+ std::fs::write(&path, &body).map_err(|e| format!("Failed to write {}: {e}", path.display()))?;
+ restrict_permissions(&path);
+ Ok(path)
+}
+
+#[cfg(unix)]
+fn restrict_permissions(path: &std::path::Path) {
+ use std::os::unix::fs::PermissionsExt;
+ let _ = std::fs::set_permissions(path, std::fs::Permissions::from_mode(0o600));
+}
+
+#[cfg(not(unix))]
+fn restrict_permissions(_path: &std::path::Path) {}
+
+/// Create or update a provider entry in `~/.jan/config.toml`, merging with any
+/// existing entry (see [`ProviderUpdate`]). Returns the config path. This is the
+/// headless write path that lets a standalone Jan Agent set credentials with no
+/// Desktop app present.
+pub(crate) fn set_provider(name: &str, update: ProviderUpdate) -> Result<PathBuf, String> {
+ if name.trim().is_empty() {
+ return Err("provider name must not be empty".to_string());
+ }
+ let mut config = load_raw()?;
+ let entry = config.providers.entry(name.to_string()).or_default();
+ if let Some(api_key) = update.api_key {
+ entry.api_key = Some(api_key);
+ }
+ if let Some(base_url) = update.base_url {
+ entry.base_url = Some(base_url);
+ }
+ if let Some(models) = update.models {
+ entry.models = models;
+ }
+ if let Some(api_type) = update.api_type {
+ entry.api_type = Some(api_type);
+ }
+ write_raw(&config)
+}
+
+/// Remove a provider entry from `~/.jan/config.toml`. Returns `true` if the
+/// provider existed and was removed, `false` if it was already absent.
+pub(crate) fn remove_provider(name: &str) -> Result<bool, String> {
+ let mut config = load_raw()?;
+ if config.providers.remove(name).is_none() {
+ return Ok(false);
+ }
+ write_raw(&config)?;
+ Ok(true)
+}
+
/// Scaffold `~/.jan/config.toml` with a commented example, if it doesn't exist
/// yet. Idempotent and clobber-safe: never overwrites an existing file.
pub(crate) fn ensure_global_config() -> Result<PathBuf, String> {
@@ -181,4 +284,132 @@ models = ["gpt-4o"]
assert!(load_global_config().is_err());
});
}
+
+ #[test]
+ fn set_provider_creates_and_roundtrips() {
+ with_temp_home(|_| {
+ set_provider(
+ "openai",
+ ProviderUpdate {
+ api_key: Some("sk-1".into()),
+ base_url: Some("https://api.openai.com/v1".into()),
+ models: Some(vec!["gpt-4o".into()]),
+ api_type: None,
+ },
+ )
+ .expect("set");
+ let configs = load_global_config().expect("load");
+ let openai = configs.get("openai").expect("present");
+ assert_eq!(openai.api_key.as_deref(), Some("sk-1"));
+ assert_eq!(openai.base_url.as_deref(), Some("https://api.openai.com/v1"));
+ assert_eq!(openai.models, vec!["gpt-4o".to_string()]);
+ });
+ }
+
+ #[test]
+ fn set_provider_merges_without_clobbering_other_fields_or_providers() {
+ with_temp_home(|_| {
+ set_provider(
+ "openai",
+ ProviderUpdate {
+ api_key: Some("sk-1".into()),
+ base_url: Some("https://a".into()),
+ models: Some(vec!["gpt-4o".into()]),
+ api_type: None,
+ },
+ )
+ .unwrap();
+ set_provider("anthropic", ProviderUpdate { api_key: Some("sk-ant".into()), ..Default::default() }).unwrap();
+ // Update only the openai key; base_url + models must survive.
+ set_provider("openai", ProviderUpdate { api_key: Some("sk-2".into()), ..Default::default() }).unwrap();
+
+ let configs = load_global_config().expect("load");
+ let openai = configs.get("openai").unwrap();
+ assert_eq!(openai.api_key.as_deref(), Some("sk-2"));
+ assert_eq!(openai.base_url.as_deref(), Some("https://a"));
+ assert_eq!(openai.models, vec!["gpt-4o".to_string()]);
+ assert_eq!(configs.get("anthropic").unwrap().api_key.as_deref(), Some("sk-ant"));
+ });
+ }
+
+ #[test]
+ fn set_provider_rejects_empty_name() {
+ with_temp_home(|_| {
+ assert!(set_provider(" ", ProviderUpdate::default()).is_err());
+ });
+ }
+
+ #[test]
+ fn default_model_none_when_empty() {
+ with_temp_home(|_| {
+ assert_eq!(default_model().expect("default"), None);
+ });
+ }
+
+ #[test]
+ fn default_model_derives_from_first_provider_model() {
+ with_temp_home(|_| {
+ set_provider("openai", ProviderUpdate { models: Some(vec!["gpt-4o".into()]), ..Default::default() }).unwrap();
+ assert_eq!(default_model().expect("default").as_deref(), Some("gpt-4o"));
+ });
+ }
+
+ #[test]
+ fn default_model_prefers_explicit_key() {
+ with_temp_home(|_| {
+ let path = global_config_path().unwrap();
+ std::fs::create_dir_all(path.parent().unwrap()).unwrap();
+ std::fs::write(
+ &path,
+ "default_model = \"claude-sonnet-5\"\n[providers.openai]\nmodels = [\"gpt-4o\"]\n",
+ )
+ .unwrap();
+ assert_eq!(default_model().expect("default").as_deref(), Some("claude-sonnet-5"));
+ });
+ }
+
+ #[test]
+ fn default_model_derivation_is_deterministic_by_provider_name() {
+ with_temp_home(|_| {
+ set_provider("zeta", ProviderUpdate { models: Some(vec!["z-model".into()]), ..Default::default() }).unwrap();
+ set_provider("alpha", ProviderUpdate { models: Some(vec!["a-model".into()]), ..Default::default() }).unwrap();
+ assert_eq!(default_model().expect("default").as_deref(), Some("a-model"));
+ });
+ }
+
+ #[test]
+ fn set_provider_preserves_default_model_key() {
+ with_temp_home(|_| {
+ let path = global_config_path().unwrap();
+ std::fs::create_dir_all(path.parent().unwrap()).unwrap();
+ std::fs::write(&path, "default_model = \"m1\"\n").unwrap();
+ set_provider("openai", ProviderUpdate { api_key: Some("sk".into()), ..Default::default() }).unwrap();
+ assert_eq!(default_model().expect("default").as_deref(), Some("m1"));
+ });
+ }
+
+ #[test]
+ fn remove_provider_reports_presence() {
+ with_temp_home(|_| {
+ set_provider("openai", ProviderUpdate { api_key: Some("sk-1".into()), ..Default::default() }).unwrap();
+ assert!(remove_provider("openai").expect("remove"));
+ assert!(!remove_provider("openai").expect("remove again"));
+ assert!(load_global_config().unwrap().get("openai").is_none());
+ });
+ }
+
+ #[test]
+ fn set_provider_preserves_commented_scaffold_is_lost_but_data_kept() {
+ // A hand-edited file with real entries roundtrips through set (comments in
+ // the scaffold are not preserved, but no provider data is lost).
+ with_temp_home(|_| {
+ let path = global_config_path().unwrap();
+ std::fs::create_dir_all(path.parent().unwrap()).unwrap();
+ std::fs::write(&path, "[providers.groq]\napi_key = \"gk\"\n").unwrap();
+ set_provider("openai", ProviderUpdate { api_key: Some("sk".into()), ..Default::default() }).unwrap();
+ let configs = load_global_config().unwrap();
+ assert_eq!(configs.get("groq").unwrap().api_key.as_deref(), Some("gk"));
+ assert_eq!(configs.get("openai").unwrap().api_key.as_deref(), Some("sk"));
+ });
+ }
}
diff --git a/src-tauri/src/core/cli/mod.rs b/src-tauri/src/core/cli/mod.rs
index aeb0e27c6..2fbe43271 100644
--- a/src-tauri/src/core/cli/mod.rs
+++ b/src-tauri/src/core/cli/mod.rs
@@ -744,6 +744,62 @@ pub fn cli_agent_status(
}))
}
+/// Set (create or merge) a provider entry in the global `~/.jan/config.toml`,
+/// the standalone-agent credential store. Returns the config path so the caller
+/// can report where the value landed. Headless: no Desktop app required.
+pub fn cli_agent_config_set(
+ provider: &str,
+ api_key: Option<String>,
+ base_url: Option<String>,
+ models: Option<Vec<String>>,
+ api_type: Option<String>,
+) -> Result<PathBuf, String> {
+ crate::core::agent::global_config::set_provider(
+ provider,
+ crate::core::agent::global_config::ProviderUpdate {
+ api_key,
+ base_url,
+ models,
+ api_type,
+ },
+ )
+}
+
+/// Remove a provider entry from `~/.jan/config.toml`. `Ok(false)` means it was
+/// already absent.
+pub fn cli_agent_config_unset(provider: &str) -> Result<bool, String> {
+ crate::core::agent::global_config::remove_provider(provider)
+}
+
+/// The global config file path, scaffolding a commented template if it doesn't
+/// exist yet so `jan agent config path` always points at a real file.
+pub fn cli_agent_config_path() -> Result<PathBuf, String> {
+ crate::core::agent::global_config::ensure_global_config()
+}
+
+/// Providers configured in `~/.jan/config.toml`, as JSON with API keys redacted.
+/// Reflects only the global store (what the user set), not Desktop inherit.
+pub fn cli_agent_config_list() -> Result<serde_json::Value, String> {
+ let configs = crate::core::agent::global_config::load_global_config()?;
+ let mut providers: Vec<serde_json::Value> = configs
+ .values()
+ .map(|c| {
+ serde_json::json!({
+ "provider": c.provider,
+ "base_url": c.base_url,
+ "has_api_key": c.api_key.is_some(),
+ "api_type": c.api_type,
+ "models": c.models,
+ })
+ })
+ .collect();
+ providers.sort_by(|a, b| a["provider"].as_str().cmp(&b["provider"].as_str()));
+ Ok(serde_json::json!({
+ "config_path": crate::core::agent::global_config::global_config_path()?.to_string_lossy(),
+ "providers": providers,
+ }))
+}
+
/// Autonomous multi-turn run to completion or the turn/token budget.
pub async fn cli_agent_run(
project: &str,
@@ -1022,13 +1078,16 @@ fn prepare_agent_session(
}
// Resolution order: --model flag, then agent.toml [agent].model, then the
- // desktop app's currently-selected model (synced from settings.json, if
- // present - purely an inherit, never required).
+ // standalone global config (~/.jan/config.toml default_model / first provider
+ // model), then the desktop app's currently-selected model (settings.json
+ // inherit). Global config outranks desktop so a standalone agent is
+ // self-sufficient without a desktop install.
let model = model_override
.or_else(|| cfg.agent.model.clone())
+ .or_else(|| crate::core::agent::global_config::default_model().ok().flatten())
.or_else(|| crate::core::cli::providers::desktop_selection().model)
.ok_or_else(|| {
- "no model specified: pass --model, set [agent].model in agent.toml, or select a model in the desktop app"
+ "no model specified: pass --model, set [agent].model in agent.toml, set default_model in ~/.jan/config.toml, or select a model in the desktop app"
.to_string()
})?;
let max_turns = max_turns_override
diff --git a/src-tauri/src/core/cli/tui.rs b/src-tauri/src/core/cli/tui.rs
index 34364d9c2..be5cd7fd8 100644
--- a/src-tauri/src/core/cli/tui.rs
+++ b/src-tauri/src/core/cli/tui.rs
@@ -131,6 +131,8 @@ enum PickerKind {
RewindMessage,
/// Second step of a rewind: restore conversation only, or + workspace.
RewindScope,
+ /// Read-only view of `~/.jan/config.toml` providers (`/config`). Enter closes.
+ ViewConfig,
}
/// Interactive list overlay (`/resume` threads, `/model` models, `/mcp`
@@ -149,6 +151,7 @@ impl Picker {
PickerKind::ToggleMcp => " mcp servers ",
PickerKind::RewindMessage => " rewind to message ",
PickerKind::RewindScope => " restore ",
+ PickerKind::ViewConfig => " provider config ",
}
}
@@ -159,6 +162,7 @@ impl Picker {
PickerKind::ToggleMcp => " ↑/↓ select Enter toggle Esc close",
PickerKind::RewindMessage => " ↑/↓ select Enter choose Esc cancel",
PickerKind::RewindScope => " ↑/↓ select Enter restore Esc cancel",
+ PickerKind::ViewConfig => " set via: jan agent config set --provider <id> ... Esc close",
}
}
}
@@ -2313,6 +2317,7 @@ async fn handle_key(
rewind_to(app, idx, value == "workspace");
}
}
+ PickerKind::ViewConfig => {}
}
}
KeyCode::Esc | KeyCode::Char('q') if !ctrl => {
@@ -2519,6 +2524,11 @@ const SLASH_COMMANDS: &[SlashCommand] = &[
hint: "",
description: "Enable/disable MCP servers",
},
+ SlashCommand {
+ name: "/config",
+ hint: "",
+ description: "View provider config (~/.jan/config.toml)",
+ },
SlashCommand {
name: "/quit",
hint: "",
@@ -2610,6 +2620,7 @@ async fn run_command(app: &mut App, line: &str) {
}
}
"mcp" => open_mcp_picker(app),
+ "config" => open_config_screen(app),
"quit" | "exit" => app.should_quit = true,
other => app.note(&format!("unknown command '/{other}' (try /help)")),
}
@@ -2756,6 +2767,48 @@ fn open_mcp_picker(app: &mut App) {
});
}
+/// Open the `/config` screen: a read-only view of the providers configured in
+/// `~/.jan/config.toml` (the standalone-agent credential store), with API keys
+/// redacted. Editing is headless via `jan agent config set/unset` (shown in the
+/// footer), since a TUI is not the safe place to type secrets.
+fn open_config_screen(app: &mut App) {
+ let configs = match crate::core::agent::global_config::load_global_config() {
+ Ok(c) => c,
+ Err(e) => return app.note(&format!("failed to read ~/.jan/config.toml: {e}")),
+ };
+ let mut providers: Vec<_> = configs.into_values().collect();
+ providers.sort_by(|a, b| a.provider.cmp(&b.provider));
+
+ let items: Vec<PickerItem> = if providers.is_empty() {
+ vec![PickerItem {
+ label: "no providers configured - run: jan agent config set --provider <id> --api-key <key>"
+ .to_string(),
+ value: String::new(),
+ hint: None,
+ checkbox: None,
+ }]
+ } else {
+ providers
+ .into_iter()
+ .map(|c| {
+ let key = if c.api_key.is_some() { "key set" } else { "no key" };
+ let base = c.base_url.as_deref().unwrap_or("default url");
+ PickerItem {
+ label: format!("{key} {base} {} model(s)", c.models.len()),
+ value: c.provider.clone(),
+ hint: Some(c.provider),
+ checkbox: None,
+ }
+ })
+ .collect()
+ };
+ app.picker = Some(Picker {
+ kind: PickerKind::ViewConfig,
+ items,
+ selected: 0,
+ });
+}
+
/// Persist a server's enabled flag and connect/disconnect it in the background
/// (off the render loop, so a cold stdio spawn never freezes the UI). Later
/// turns read the shared map fresh, so tools appear/vanish once the task lands.
@@ -3794,10 +3847,11 @@ mod tests {
use super::{
build_user_message, clipboard_path, diff_lines, group_activity, group_detail_lines,
group_summary, handle_key, handle_mouse, image_mime, input_content_lines, is_table_separator, load_image_file,
- message_text, parse_command, render_table, run_command, running_group_row, split_reasoning,
- subagent_activity, subagent_name_from_run_id, summarize_result, tool_activity,
- tool_finished, transcript_top_padding, user_content_parts, App, CurrentRun, Pending,
- PendingImage, SnapshotJob, DIFF_MAX_ROWS, SLASH_COMMANDS, SPINNER,
+ message_text, open_config_screen, parse_command, render_table, run_command,
+ running_group_row, split_reasoning, subagent_activity, subagent_name_from_run_id,
+ summarize_result, tool_activity, tool_finished, transcript_top_padding,
+ user_content_parts, App, CurrentRun, Pending, PendingImage, PickerKind, SnapshotJob,
+ DIFF_MAX_ROWS, SLASH_COMMANDS, SPINNER,
};
use ratatui::crossterm::event::{
KeyCode, KeyEvent, KeyModifiers, MouseButton, MouseEvent, MouseEventKind,
@@ -3887,6 +3941,18 @@ mod tests {
assert!(text.contains("+ hi"), "diff content missing: {text}");
}
+ #[test]
+ fn config_screen_opens_as_readonly_viewer() {
+ let mut app = test_app();
+ open_config_screen(&mut app);
+ let picker = app.picker.as_ref().expect("config screen opens a picker");
+ assert!(picker.kind == PickerKind::ViewConfig);
+ // Always at least one row: real providers, or the "no providers" hint.
+ assert!(!picker.items.is_empty());
+ // Enter is a no-op close (never mutates model/thread), matching the arm.
+ assert!(picker.title().contains("config"));
+ }
+
#[test]
fn exec_permission_prompt_has_no_diff_preview() {
let mut app = test_app();