fix(acp): harden session-page connection and localize backend errors
- Session-page connect never triggers download/install; returns SdkNotInstalled immediately and prompts the user to install from Agent Settings instead - Binary agents now accept any cached version via find_best_cached_binary_for_agent so stale caches still connect - Bound Initialize handshake with a 60s timeout and convert it to AcpError::InitializeTimeout via a sentinel in run_connection - Spawn background task owns ConnectionManager map insertion and removes the entry on exit through an RAII guard that survives panics, preventing leaked stale entries - AcpError gains SdkNotInstalled and InitializeTimeout variants plus a stable code() identifier; AcpEvent::Error carries code so the frontend can render localized messages by key - Frontend preflight now runs for all connect sources; error event handler switches on code to show translated text for initialize_timeout, sdk_not_installed, platform_not_supported, process_exited, spawn_failed and download_failed - Remove ConnectionStatus::Downloading enum variant, all frontend branches, and i18n strings; drop obsolete autoLinkFailedTitle, autoLinkPreflightFailed, preflightCheckFailedDefault and preflightFailedTitle keys across 10 locales - Add backendErrors.* translations in 10 languages - Diagnostic logging: always log agent stderr plus binary path/size/args/env keys and Initialize timing; gate stdin/stdout JSON-RPC tracing behind CODEG_ACP_DEBUG to avoid persisting user content into OS log files Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -133,6 +133,34 @@ pub fn detect_installed_version(
|
||||
installed_version_for_agent(agent_type, cmd_name)
|
||||
}
|
||||
|
||||
/// Return the best cached binary across all installed versions.
|
||||
///
|
||||
/// This returns the path + version label of the highest semver-ish
|
||||
/// version cached on disk, regardless of what the registry considers
|
||||
/// the "recommended" version. The session-page connect path uses this
|
||||
/// to tolerate older-but-still-usable cached binaries (e.g. the user
|
||||
/// hasn't upgraded yet) — the Settings page will continue to surface
|
||||
/// an "upgrade available" hint via the separate version-badge path.
|
||||
///
|
||||
/// Returns Ok(None) when no usable binary is cached.
|
||||
pub fn find_best_cached_binary_for_agent(
|
||||
agent_type: AgentType,
|
||||
cmd_name: &str,
|
||||
) -> Result<Option<(PathBuf, String)>, AcpError> {
|
||||
let agent_id = agent_cache_key(agent_type);
|
||||
let mut versions = installed_version_labels(&agent_id, cmd_name)?;
|
||||
if versions.is_empty() {
|
||||
return Ok(None);
|
||||
}
|
||||
versions.sort_by(|a, b| version_cmp(a, b));
|
||||
while let Some(version) = versions.pop() {
|
||||
if let Some(path) = installed_binary_path(&agent_id, &version, cmd_name) {
|
||||
return Ok(Some((path, version)));
|
||||
}
|
||||
}
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
fn version_cmp(a: &str, b: &str) -> std::cmp::Ordering {
|
||||
let mut a_parts = parse_version_parts(a);
|
||||
let mut b_parts = parse_version_parts(b);
|
||||
|
||||
Reference in New Issue
Block a user