Skip to content

armgit / Wake

Public Imported from GitHub
0

All your AI agent sessions in one place — browse, search, resume. Rust + GPUI.

Rust

fix(terminal): clarify missing agent CLI errors

Corey Chiu25c807883382
diff --git a/crates/wake-core/src/services/terminal/macos.rs b/crates/wake-core/src/services/terminal/macos.rs
index 8f834e3..34a50b5 100644
--- a/crates/wake-core/src/services/terminal/macos.rs
+++ b/crates/wake-core/src/services/terminal/macos.rs
@@ -3,8 +3,8 @@
//! 线程化)在 mod.rs,这里只做动作本身。
use super::{
- percent_encode, pipe_to, posix_quote, resolve_cli, resume_args, session_bin, spawn_and_reap,
- ResumeOutcome,
+ cli_not_found_error, percent_encode, pipe_to, posix_quote, resolve_cli, resume_args,
+ session_bin, spawn_and_reap, ResumeOutcome,
};
use crate::models::{AgentId, SessionMeta};
use std::collections::HashMap;
@@ -320,10 +320,7 @@ fn launch_kooky_cli(meta: &SessionMeta) -> ResumeOutcome {
// 顺带承担"装没装"的判断:少了这步,kooky 会开出一个只写着 command not
// found 的 tab,而 Wake 这边照报成功
let Some(exe) = resolve_cli(bin) else {
- return fail(
- String::new(),
- format!("Command {bin} not found — is it installed?"),
- );
+ return fail(String::new(), cli_not_found_error(meta.agent, bin));
};
let cmd = std::iter::once(exe.as_str())
.chain(args.iter().map(|s| s.as_str()))
diff --git a/crates/wake-core/src/services/terminal/mod.rs b/crates/wake-core/src/services/terminal/mod.rs
index eca17d5..64cfda5 100644
--- a/crates/wake-core/src/services/terminal/mod.rs
+++ b/crates/wake-core/src/services/terminal/mod.rs
@@ -112,6 +112,16 @@ fn session_bin(meta: &SessionMeta) -> Option<&'static str> {
}
}
+/// 明确区分“用来打开的终端”与“要在终端里跑的 agent CLI”。
+/// 用 PATH 而非 shell PATH:POSIX 经 login shell 探测,Windows 则直接遍历
+/// PATH × PATHEXT,这一份文案必须在三端都准确。
+fn cli_not_found_error(agent: AgentId, bin: &str) -> String {
+ format!(
+ "Agent CLI `{bin}` for {} was not found on PATH — is it installed and available to Wake?",
+ agent.display_name()
+ )
+}
+
pub fn agent_bin(agent: AgentId) -> Option<&'static str> {
match agent {
AgentId::ClaudeCode => Some("claude"),
@@ -180,10 +190,7 @@ pub fn resume_session_in(meta: &SessionMeta, term: TerminalApp) -> ResumeOutcome
return ResumeOutcome {
ok: false,
command: String::new(),
- error: Some(format!(
- "Command {} not found — is it installed?",
- bin.unwrap_or("?")
- )),
+ error: Some(cli_not_found_error(meta.agent, bin.unwrap_or("?"))),
};
};
let cwd_ok = !meta.project_path.is_empty() && Path::new(&meta.project_path).is_dir();
@@ -295,7 +302,8 @@ fn spawn_and_reap(mut cmd: Command) -> std::io::Result<()> {
#[cfg(test)]
mod tests {
- use super::resolve_clis_with;
+ use super::{cli_not_found_error, resolve_clis_with};
+ use crate::models::AgentId;
use std::cell::Cell;
use std::collections::HashMap;
@@ -336,4 +344,20 @@ mod tests {
assert_eq!(second, first);
assert_eq!(probes.get(), 0);
}
+
+ #[test]
+ fn cli_not_found_error_names_agent_and_cli() {
+ assert_eq!(
+ cli_not_found_error(AgentId::Omp, "omp"),
+ "Agent CLI `omp` for Oh My Pi was not found on PATH — is it installed and available to Wake?"
+ );
+ }
+
+ #[test]
+ fn cli_not_found_error_keeps_session_specific_cli() {
+ assert_eq!(
+ cli_not_found_error(AgentId::Opencode, "opencode2"),
+ "Agent CLI `opencode2` for OpenCode was not found on PATH — is it installed and available to Wake?"
+ );
+ }
}