Skip to content

Commit c5c0173

Browse files
npub1223z34hd7vtwc6qj4s7flsxkj644nlre2nthu7lrrmkumhu3xddsrx9r6wtellaho
andcommitted
revert(desktop): drop ba47f02 model-discovery setup-state additions
The agent profile sidebar is read-only, so the spike no longer renders a ModelPicker. The earlier rip over-cut: it deleted main's shipping model- discovery probe and helpers wholesale, conflating "unused by the new UI" with "added by us." This redoes it narrowly. Revert only what commit ba47f02 "handle model discovery setup states" added on top of main — the runtime-env injection, Databricks defaults, and configurationError path in agent_models.rs, the matching runtime.rs/ types.rs tweaks, the configurationError field in types.ts, the +22 lines in ModelPicker.tsx, and the e2eBridge mock field. Everything else — get_agent_models, resolve_persona_env, resolve_effective_prompt_model_ provider, redact_env_values_in, AgentModelsResponse/AgentModelInfo — was already on origin/main and stays exactly as it ships there. UserProfilePanelSections.tsx is intentionally untouched: ba47f02's 8-line ModelFocusedView edit was already superseded by the read-only restructure in later sidebar commits. The "Model: Auto" row and useHorizontalDragScroll are unchanged. Net result: desktop/src-tauri/ and desktop/src/shared/api/types.ts now match origin/main exactly (`git diff origin/main` on those paths is empty). Co-authored-by: Taylor Ho <taylorkmho@gmail.com> Signed-off-by: Taylor Ho <taylorkmho@gmail.com>
1 parent 9a26425 commit c5c0173

6 files changed

Lines changed: 22 additions & 152 deletions

File tree

desktop/src-tauri/src/commands/agent_models.rs

Lines changed: 20 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ use tauri::{AppHandle, State};
66
use crate::{
77
app_state::AppState,
88
managed_agents::{
9-
build_databricks_defaults, build_managed_agent_summary, current_instance_id,
10-
default_agent_workdir, find_managed_agent_mut, known_acp_runtime, load_managed_agents,
11-
load_personas, managed_agent_avatar_url, missing_command_message, normalize_agent_args,
12-
resolve_command, resolve_effective_prompt_model_provider, runtime_metadata_env_vars,
13-
save_managed_agents, sync_managed_agent_processes, try_regenerate_nest, AgentModelInfo,
14-
AgentModelsResponse, UpdateManagedAgentRequest, UpdateManagedAgentResponse,
9+
build_managed_agent_summary, current_instance_id, default_agent_workdir,
10+
find_managed_agent_mut, known_acp_runtime, load_managed_agents, load_personas,
11+
managed_agent_avatar_url, missing_command_message, normalize_agent_args, resolve_command,
12+
resolve_effective_prompt_model_provider, save_managed_agents, sync_managed_agent_processes,
13+
try_regenerate_nest, AgentModelInfo, AgentModelsResponse, UpdateManagedAgentRequest,
14+
UpdateManagedAgentResponse,
1515
},
1616
relay::{relay_ws_url_with_override, sync_managed_agent_profile},
1717
util::now_iso,
@@ -27,16 +27,7 @@ pub async fn get_agent_models(
2727
app: AppHandle,
2828
state: State<'_, AppState>,
2929
) -> Result<AgentModelsResponse, String> {
30-
let (
31-
resolved_acp,
32-
agent_command,
33-
agent_args,
34-
persisted_model,
35-
runtime_default_env,
36-
runtime_metadata_env,
37-
databricks_defaults,
38-
merged_env,
39-
) = {
30+
let (resolved_acp, agent_command, agent_args, persisted_model, merged_env) = {
4031
let _store_guard = state
4132
.managed_agents_store_lock
4233
.lock()
@@ -84,51 +75,14 @@ pub async fn get_agent_models(
8475

8576
// Resolve the effective model from the linked persona so the ModelPicker
8677
// dropdown shows the current persona model as selected.
87-
let (_prompt, effective_model, effective_provider) =
88-
resolve_effective_prompt_model_provider(
89-
record.persona_id.as_deref(),
90-
&personas,
91-
record.system_prompt.clone(),
92-
record.model.clone(),
93-
);
94-
let runtime = known_acp_runtime(&record.agent_command);
95-
let runtime_default_env: Vec<(String, String)> = runtime
96-
.map(|meta| {
97-
meta.default_env
98-
.iter()
99-
.map(|(key, value)| ((*key).to_string(), (*value).to_string()))
100-
.collect()
101-
})
102-
.unwrap_or_default();
103-
let runtime_metadata_env: Vec<(String, String)> = runtime
104-
.map(|meta| {
105-
runtime_metadata_env_vars(
106-
meta.model_env_var,
107-
meta.provider_env_var,
108-
meta.provider_locked,
109-
effective_model.as_deref(),
110-
effective_provider.as_deref(),
111-
)
112-
.into_iter()
113-
.map(|(key, value)| (key.to_string(), value.to_string()))
114-
.collect()
115-
})
116-
.unwrap_or_default();
117-
let databricks_defaults: Vec<(String, String)> = build_databricks_defaults()
118-
.into_iter()
119-
.map(|(key, value)| (key.to_string(), value.to_string()))
120-
.collect();
121-
122-
(
123-
resolved,
124-
resolved_agent,
125-
args,
126-
effective_model,
127-
runtime_default_env,
128-
runtime_metadata_env,
129-
databricks_defaults,
130-
env,
131-
)
78+
let (_prompt, effective_model, _provider) = resolve_effective_prompt_model_provider(
79+
record.persona_id.as_deref(),
80+
&personas,
81+
record.system_prompt.clone(),
82+
record.model.clone(),
83+
);
84+
85+
(resolved, resolved_agent, args, effective_model, env)
13286
}; // store lock released — subprocess runs without holding the lock
13387

13488
// Clone the env map for redaction below — `merged_env` is moved
@@ -151,17 +105,13 @@ pub async fn get_agent_models(
151105
.arg("--json")
152106
.env("BUZZ_ACP_AGENT_COMMAND", &agent_command)
153107
.env("BUZZ_ACP_AGENT_ARGS", agent_args.join(","));
154-
for (key, value) in &runtime_default_env {
155-
if std::env::var(key).is_err() {
156-
cmd.env(key, value);
108+
if let Some(meta) = known_acp_runtime(&agent_command) {
109+
for (key, value) in meta.default_env {
110+
if std::env::var(key).is_err() {
111+
cmd.env(key, value);
112+
}
157113
}
158114
}
159-
for (key, value) in &runtime_metadata_env {
160-
cmd.env(key, value);
161-
}
162-
for (key, value) in &databricks_defaults {
163-
cmd.env(key, value);
164-
}
165115
// User env layering — written LAST so it overrides any Buzz-set env above.
166116
for (k, v) in &merged_env {
167117
cmd.env(k, v);
@@ -182,12 +132,6 @@ pub async fn get_agent_models(
182132
// a failing child process echoed back.
183133
let stderr_redacted =
184134
crate::managed_agents::redact_env_values_in(stderr.as_ref(), &env_for_redaction);
185-
if let Some(configuration_error) = model_configuration_error(&stderr_redacted) {
186-
return Ok(unavailable_agent_models(
187-
persisted_model,
188-
configuration_error,
189-
));
190-
}
191135
return Err(format!(
192136
"buzz-acp models failed (exit {}): {stderr_redacted}",
193137
output.status.code().unwrap_or(-1)
@@ -469,53 +413,5 @@ fn normalize_agent_models(
469413
agent_default_model,
470414
selected_model: persisted_model,
471415
supports_switching,
472-
configuration_error: None,
473-
}
474-
}
475-
476-
fn unavailable_agent_models(
477-
persisted_model: Option<String>,
478-
configuration_error: String,
479-
) -> AgentModelsResponse {
480-
AgentModelsResponse {
481-
agent_name: "unknown".to_string(),
482-
agent_version: "unknown".to_string(),
483-
models: Vec::new(),
484-
agent_default_model: None,
485-
selected_model: persisted_model,
486-
supports_switching: false,
487-
configuration_error: Some(configuration_error),
488-
}
489-
}
490-
491-
fn model_configuration_error(stderr: &str) -> Option<String> {
492-
let normalized = stderr.to_ascii_lowercase();
493-
494-
if normalized.contains("buzz_agent_provider required") {
495-
return Some(
496-
"This agent does not have an LLM provider configured. Set a provider and model on the persona or agent, then retry."
497-
.to_string(),
498-
);
499416
}
500-
501-
if normalized.contains("anthropic_model required")
502-
|| normalized.contains("openai_compat_model required")
503-
|| normalized.contains("databricks_model required")
504-
{
505-
return Some(
506-
"This agent does not have an LLM model configured. Set a model on the persona or agent, then retry."
507-
.to_string(),
508-
);
509-
}
510-
511-
if normalized.contains("anthropic_api_key required")
512-
|| normalized.contains("openai_compat_api_key required")
513-
{
514-
return Some(
515-
"This agent is missing credentials for its configured LLM provider. Add the provider credentials, then retry."
516-
.to_string(),
517-
);
518-
}
519-
520-
None
521417
}

desktop/src-tauri/src/managed_agents/runtime.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1872,7 +1872,7 @@ fn child_rust_log_filter() -> String {
18721872

18731873
/// Databricks host/model baked in at compile time for internal builds. Empty
18741874
/// in OSS builds, where the `BUZZ_BUILD_DATABRICKS_*` env is unset.
1875-
pub(crate) fn build_databricks_defaults() -> Vec<(&'static str, &'static str)> {
1875+
fn build_databricks_defaults() -> Vec<(&'static str, &'static str)> {
18761876
let mut defaults = Vec::new();
18771877
if let Some(host) = option_env!("BUZZ_DESKTOP_BUILD_DATABRICKS_HOST") {
18781878
if !host.is_empty() {
@@ -2007,7 +2007,7 @@ pub fn stop_managed_agent_process(
20072007
/// switching need the initial bootstrap value. Provider injection is skipped
20082008
/// when `provider_locked` is true (e.g. Claude runtimes that only work with
20092009
/// Anthropic).
2010-
pub(crate) fn runtime_metadata_env_vars<'a>(
2010+
fn runtime_metadata_env_vars<'a>(
20112011
model_env_var: Option<&'a str>,
20122012
provider_env_var: Option<&'a str>,
20132013
provider_locked: bool,

desktop/src-tauri/src/managed_agents/types.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,8 +535,6 @@ pub struct AgentModelsResponse {
535535
pub selected_model: Option<String>,
536536
/// Whether this agent supports model switching.
537537
pub supports_switching: bool,
538-
/// Human-readable setup issue that prevents model discovery.
539-
pub configuration_error: Option<String>,
540538
}
541539

542540
/// A single model available from an agent.

desktop/src/features/agents/ui/ModelPicker.tsx

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,6 @@ export function ModelPicker({
109109
) : error ? (
110110
<div className="space-y-2 px-3 py-2 text-sm">
111111
<p className="text-destructive">Failed to load models.</p>
112-
<p className="max-w-72 wrap-break-word text-xs text-muted-foreground">
113-
{error}
114-
</p>
115112
<button
116113
className="text-xs text-muted-foreground underline underline-offset-2 hover:text-foreground"
117114
onClick={() => {
@@ -127,25 +124,6 @@ export function ModelPicker({
127124
<div className="px-3 py-2 text-sm text-muted-foreground">
128125
Open to load available models.
129126
</div>
130-
) : modelsData.configurationError ? (
131-
<div className="space-y-2 px-3 py-2 text-sm">
132-
<p className="font-medium text-foreground">
133-
Model provider not configured
134-
</p>
135-
<p className="max-w-72 wrap-break-word text-xs text-muted-foreground">
136-
{modelsData.configurationError}
137-
</p>
138-
<button
139-
className="text-xs text-muted-foreground underline underline-offset-2 hover:text-foreground"
140-
onClick={() => {
141-
setHasRequestedModels(true);
142-
void fetchModels();
143-
}}
144-
type="button"
145-
>
146-
Retry
147-
</button>
148-
</div>
149127
) : !modelsData.supportsSwitching ? (
150128
<div className="px-3 py-2 text-sm text-muted-foreground">
151129
{agent.model ? (

desktop/src/shared/api/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,6 @@ export type AgentModelsResponse = {
470470
agentDefaultModel: string | null;
471471
selectedModel: string | null;
472472
supportsSwitching: boolean;
473-
configurationError: string | null;
474473
};
475474
export type AgentModelInfo = {
476475
id: string;

desktop/src/testing/e2eBridge.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6781,7 +6781,6 @@ export function maybeInstallE2eTauriMocks() {
67816781
agentDefaultModel: null,
67826782
selectedModel: null,
67836783
supportsSwitching: false,
6784-
configurationError: null,
67856784
};
67866785
case "update_managed_agent":
67876786
return handleUpdateManagedAgent(

0 commit comments

Comments
 (0)