Skip to content

Commit d5e5589

Browse files
committed
fix(dashboard): include ~/.opencode/bin in opencode binary lookup
The Rust `get_available_models` command spawns `opencode models` to populate the model picker for historian / dreamer / sidekick primary and fallback dropdowns. GUI processes on macOS don't inherit shell PATH, so the command tries an explicit list of candidate binary paths. The previous candidate list missed the most important one: the official OpenCode installer (`curl -fsSL https://opencode.ai/install | bash`) writes the binary to `~/.opencode/bin/opencode`, NOT to ~/.local/bin or anywhere else in the previous candidate list. Users with a stock OpenCode install therefore got an empty `models()` array in the dashboard, which made every model dropdown render the `<For fallback>` empty-state ("No models found"). This bug masqueraded as a `fallback_models` filter problem in v0.3.3 because the user-visible symptom was the same — but the v0.3.3 fix (string-vs-array normalization in the dropdown filter) only addressed one of two distinct empty-dropdown causes. This commit fixes the deeper one: `models()` itself was empty. Promoted `~/.opencode/bin/opencode` to the first candidate on macOS and Linux. Also added `%USERPROFILE%\.opencode\bin\opencode.exe` as the first Windows candidate for symmetry. The shell-PATH `opencode` fallback remains for users who launch OpenCode from a terminal. After upgrade, the existing `availableModels` localStorage cache (empty `[]` from a prior failed lookup) is overwritten by the next `onMount` refresh, so users will see populated dropdowns on first launch of the upgraded build with no manual cache clear required. Verified: cargo check clean, dashboard frontend build clean.
1 parent b47831b commit d5e5589

1 file changed

Lines changed: 22 additions & 6 deletions

File tree

packages/dashboard/src-tauri/src/commands.rs

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -355,16 +355,32 @@ pub fn save_project_config(project_path: String, content: String) -> Result<(),
355355

356356
#[tauri::command]
357357
pub async fn get_available_models() -> Vec<String> {
358-
// GUI apps on macOS don't inherit shell PATH; try common locations
358+
// GUI apps on macOS don't inherit shell PATH; try common locations.
359+
//
360+
// The first candidate must be `~/.opencode/bin/opencode` because that's
361+
// the path the official OpenCode installer (`curl -fsSL ... | bash`)
362+
// writes to and it's NOT on the GUI launcher's $PATH on macOS. Without
363+
// this candidate, every dashboard model dropdown silently returned
364+
// empty for users with a stock OpenCode install — the historian /
365+
// dreamer / sidekick fallback "Add fallback model" dropdown would show
366+
// "No models found" because `props.models = []`, so `grouped()`
367+
// returned no groups and the `<For fallback>` rendered.
368+
//
369+
// Additional fallback paths cover pre-CI installs, custom installs,
370+
// Homebrew on Intel + ARM, and shell-PATH discovery for users who
371+
// launched OpenCode from a terminal.
359372
let candidates = if cfg!(target_os = "windows") {
360-
vec!["opencode".to_string()]
373+
let home = std::env::var("USERPROFILE").unwrap_or_default();
374+
vec![
375+
format!("{}\\.opencode\\bin\\opencode.exe", home),
376+
"opencode".to_string(),
377+
]
361378
} else {
379+
let home = std::env::var("HOME").unwrap_or_default();
362380
vec![
381+
format!("{}/.opencode/bin/opencode", home),
363382
"opencode".to_string(),
364-
format!(
365-
"{}/.local/bin/opencode",
366-
std::env::var("HOME").unwrap_or_default()
367-
),
383+
format!("{}/.local/bin/opencode", home),
368384
"/usr/local/bin/opencode".to_string(),
369385
"/opt/homebrew/bin/opencode".to_string(),
370386
]

0 commit comments

Comments
 (0)