diff --git a/apps/ai-game-creator-shell/src-tauri/src/agent/direct_project_history.rs b/apps/ai-game-creator-shell/src-tauri/src/agent/direct_project_history.rs index b2d46416d..a4f40e846 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/agent/direct_project_history.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/agent/direct_project_history.rs @@ -560,13 +560,9 @@ mod tests { #[test] fn legacy_conversation_rows_project_into_responses_message_items() { let root = init_history_project("legacy-projection"); - write_history_lines( - root.path(), - &[LEGACY_USER_ROW, LEGACY_ASSISTANT_ROW], - ); + write_history_lines(root.path(), &[LEGACY_USER_ROW, LEGACY_ASSISTANT_ROW]); - let items = - read_direct_project_history_items_at(root.path()).expect("read legacy history"); + let items = read_direct_project_history_items_at(root.path()).expect("read legacy history"); assert_eq!( items, vec![ @@ -611,7 +607,11 @@ mod tests { .iter() .map(|item| item.get("id").and_then(Value::as_str)) .collect::>(), - vec![Some("direct-codex:turn-0001:user"), Some("codex-item-2"), None] + vec![ + Some("direct-codex:turn-0001:user"), + Some("codex-item-2"), + None + ] ); assert_eq!( items[1], @@ -622,7 +622,10 @@ mod tests { "content": [{"type": "input_text", "text": "再加一个按钮"}], }) ); - assert_eq!(items[2]["content"][0]["text"], json!("已完成 第一行\n第二行 ")); + assert_eq!( + items[2]["content"][0]["text"], + json!("已完成 第一行\n第二行 ") + ); let chat = read_direct_project_chat_history_at(root.path()).expect("read mixed chat"); assert_eq!( diff --git a/apps/ai-game-creator-shell/src-tauri/src/agent/direct_runtime.rs b/apps/ai-game-creator-shell/src-tauri/src/agent/direct_runtime.rs index 72116eadc..bc7d7b0e7 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/agent/direct_runtime.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/agent/direct_runtime.rs @@ -4571,7 +4571,8 @@ mod tests { #[test] fn direct_project_history_shape_failure_has_explicit_non_retryable_guidance() { - let error = "DirectProject 历史记录类型无效:$PROJECT_ROOT/.agent/conversations/project.jsonl"; + let error = + "DirectProject 历史记录类型无效:$PROJECT_ROOT/.agent/conversations/project.jsonl"; assert!(direct_project_history_shape_failure(error)); assert_eq!( direct_codex_failure_recovery_hint(DirectCodexFailureStage::CodeGeneration, error), diff --git a/apps/ai-game-creator-shell/src-tauri/src/main.rs b/apps/ai-game-creator-shell/src-tauri/src/main.rs index 9dec92e39..94e835a7c 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/main.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/main.rs @@ -30,8 +30,8 @@ use shared_contracts::game_creation_app::{ game_creation_app_asset_effective_category, new_game_creation_app_manifest, new_game_creation_app_seed_tasks, normalize_game_creation_app_asset_tags, validate_game_iteration_versions, GameCreationAgentArtifactTrace, - GameCreationAgentCapabilityDescriptor, - GameCreationAgentPassPlanTrace, GameCreationAgentRepairRouteTrace, GameCreationAgentRunStep, + GameCreationAgentCapabilityDescriptor, GameCreationAgentPassPlanTrace, + GameCreationAgentRepairRouteTrace, GameCreationAgentRunStep, GameCreationAgentRunTaskGraphTrace, GameCreationAgentRunTrace, GameCreationAgentToolCallTrace, GameCreationAppAgentGroup, GameCreationAppAssetManifestEntry, GameCreationAppAssetSource, GameCreationAppAssetSourceKind, GameCreationAppCommandRunState, diff --git a/apps/ai-game-creator-shell/src-tauri/src/project/conversation.rs b/apps/ai-game-creator-shell/src-tauri/src/project/conversation.rs index f8a6ff808..3e0e26294 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/project/conversation.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/project/conversation.rs @@ -958,19 +958,18 @@ fn read_persisted_local_conversation_records_unlocked( if line.is_empty() { continue; } - let record = match serde_json::from_str::( - line, - ) { - Ok(record) => record, - // 项目主对话(agent_id=None)与 DirectProject 共用同一份 - // `project.jsonl`:DirectProject 写的是 Codex rollout 的 - // `response_item` 行。通用对话链只认自己的 legacy 行,遇到对方那种 - // 行就跳过;其余任何坏行继续失败关闭。 - Err(_) if is_direct_project_history_row(line) => continue, - Err(error) => { - return Err(format!("解析对话记录失败:{}: {error}", path.display())) - } - }; + let record = + match serde_json::from_str::(line) { + Ok(record) => record, + // 项目主对话(agent_id=None)与 DirectProject 共用同一份 + // `project.jsonl`:DirectProject 写的是 Codex rollout 的 + // `response_item` 行。通用对话链只认自己的 legacy 行,遇到对方那种 + // 行就跳过;其余任何坏行继续失败关闭。 + Err(_) if is_direct_project_history_row(line) => continue, + Err(error) => { + return Err(format!("解析对话记录失败:{}: {error}", path.display())) + } + }; records.push(record); } } diff --git a/apps/ai-game-creator-shell/src-tauri/src/project/conversation/tests.rs b/apps/ai-game-creator-shell/src-tauri/src/project/conversation/tests.rs index 288f2e84c..9bad4a007 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/project/conversation/tests.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/project/conversation/tests.rs @@ -293,7 +293,10 @@ fn mixed_project_history_rows_stay_readable_from_both_sides() { let history = std::fs::read_to_string(project_conversation_path(&root)).expect("read history"); assert_eq!(history.lines().count(), 3, "{history}"); - assert!(history.contains("模式切换后由通用写入器补写的回复"), "{history}"); + assert!( + history.contains("模式切换后由通用写入器补写的回复"), + "{history}" + ); // 通用对话链只读自己的 legacy 行,跳过 DirectProject 的行。 let conversation = read_local_conversation_at(&root, None).expect("read project conversation"); @@ -332,7 +335,10 @@ fn project_history_keeps_accepting_legacy_rows_while_no_direct_project_row_exist append_project_message(&root, "非 direct 模式的项目对话回复").expect("append legacy row"); let conversation = read_local_conversation_at(&root, None).expect("read legacy conversation"); assert_eq!(conversation.messages.len(), 1); - assert_eq!(conversation.messages[0].content, "非 direct 模式的项目对话回复"); + assert_eq!( + conversation.messages[0].content, + "非 direct 模式的项目对话回复" + ); std::fs::remove_dir_all(root).ok(); }