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:
xintaofei
2026-04-12 03:36:08 +08:00
parent 5bda7d06e9
commit 1c1738298b
25 changed files with 595 additions and 255 deletions

View File

@@ -851,7 +851,6 @@
"connection": {
"connected": "已連線",
"connecting": "連線中...",
"downloading": "下載中...",
"prompting": "回應中...",
"error": "連線異常",
"disconnected": "未連線",
@@ -1422,11 +1421,13 @@
"unavailable": "{agent} 目前平台不可用。",
"sdkMissing": "{agent} SDK 尚未安裝"
},
"backendErrors": {
"initializeTimeout": "{agent} 連線交握逾時60 秒未回應),請前往設定頁面檢查智能體與網路設定。",
"processExited": "{agent} 處理程序意外結束。",
"spawnFailed": "啟動 {agent} 失敗:{message}",
"downloadFailed": "{agent} 下載失敗:{message}"
},
"unableReadAgentConfig": "無法讀取 Agent 設定:{message}",
"autoLinkFailedTitle": "{agent} 自動連結失敗",
"preflightCheckFailedDefault": "預檢查未通過,請檢查 Agent 設定。",
"preflightFailedTitle": "{agent} 預檢查失敗",
"autoLinkPreflightFailed": "自動連結預檢查失敗:{message}",
"connectFailedTitle": "{agent} 連線失敗",
"toolFallbackTitle": "工具",
"eventErrorTitle": "Agent 錯誤",