修复运行时配置诊断阻塞窗口
Project CI / Repository checks (pull_request) Failing after 15s
Project CI / Backend tests (pull_request) Failing after 15s
Project CI / Native shell tests (pull_request) Failing after 11m21s
Project CI / Frontend tests (pull_request) Successful in 11m46s

将 Codex CLI 与 app-server 探测移入 Tokio 阻塞线程池

保持 GameAgent 运行时配置读写流程不变

增加异步 LLM 配置诊断回归测试并补充技术方案约束
This commit is contained in:
2026-09-03 14:24:40 +08:00
parent 75845bd7e9
commit 8aaa3f5c7b
3 changed files with 36 additions and 2 deletions
@@ -1832,8 +1832,14 @@ pub(crate) fn schedule_game_creator_agent_ready_tasks(
}
#[tauri::command]
pub(crate) fn check_game_creator_llm_config() -> GameCreatorLlmConfigStatus {
check_game_creator_llm_config_from_config()
pub(crate) async fn check_game_creator_llm_config() -> Result<GameCreatorLlmConfigStatus, String> {
// Configuration reads/writes are short local file operations, but the
// diagnostic status path may synchronously spawn Codex CLI and run
// `app-server --help`. Keep that blocking probe off Tauri's async/window
// thread so opening or saving runtime settings never freezes the shell.
tokio::task::spawn_blocking(check_game_creator_llm_config_from_config)
.await
.map_err(|error| format!("LLM 配置诊断任务意外终止:{error}"))
}
#[tauri::command]
@@ -1097,6 +1097,33 @@ fn llm_config_check_reports_agent_specific_config_paths() {
fs::remove_dir_all(root).ok();
}
#[tokio::test]
async fn llm_config_diagnostic_command_runs_asynchronously() {
let root = unique_project_path();
fs::create_dir_all(&root).expect("create runtime config dir");
let _guard = use_test_runtime_config_dir(root.clone());
fs::write(
root.join(GAME_CREATOR_CONFIG_FILE_NAME),
r#"{
"agentMode": "provider",
"llm": {
"apiKey": "test-key",
"baseUrl": "https://example.test/v1",
"model": "test-model"
}
}
"#,
)
.expect("write runtime config");
let status = crate::commands::check_game_creator_llm_config()
.await
.expect("run config diagnostic command");
assert!(status.configured, "{status:?}");
fs::remove_dir_all(root).ok();
}
#[test]
fn llm_status_cli_lines_include_agent_errors_without_leaking_keys() {
let status = GameCreatorLlmConfigStatus {
@@ -1617,6 +1617,7 @@ V1.51 在不替换现有 Provider、Runner 和 Runtime 事实源的前提下增
### 配置与验收
- `check_game_creator_llm_config` 在 CLI 模式只检查固定 Codex 可执行文件可启动并返回受支持版本,不要求 LLM API Key;Provider 模式保持既有检查。配置 UI 显示全局模式,始终保留旧 LLM/逐 Agent/MCP/Editor 配置;切换模式不清空任何旧值。
- Tauri 配置页触发的 `check_game_creator_llm_config` 必须通过阻塞线程池执行 Codex CLI / app-server 探测,不能在窗口线程同步等待;配置文件读写不得因诊断探测阻塞整个 GameAgent 窗口。
- fake Codex fixture 必须覆盖 argv/stdin、structured calls、final text、非零退出、挂起取消、损坏/超限 JSONL、无 shell/MCP 参数和并发节点;真实 smoke 只复用用户已有 Codex 登录态。旧 Provider smoke 继续作为回退模式门禁,不能被新 CLI smoke 替代。
## V1.52 Codex app-server 长期节点 Agent 模式