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(codebuddy): recognize the metadata records newer versions write (#66)

Corey Chiu44656dc507f8
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b25c8ea..8eef552 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,7 @@
- Fix: Refresh picks up sessions you deleted in OpenCode while it was still running, instead of listing them until Wake restarts (#70, thanks @lin-code-world)
- Fix: On Windows and Linux, adding a memory location offers a file picker next to the folder picker, so a single file no longer has to be typed in by hand (#68, thanks @lin-code-world)
- New: A memory location can be written as `<project>/CODEBUDDY.md`, like the built-in project files, to read that file or folder in every project (#67, thanks @lin-code-world)
+- Fix: Clean Up no longer refuses CodeBuddy and WorkBuddy sessions written by recent versions (#66, thanks @lin-code-world)
## [0.9.3] — 2026-10-13
diff --git a/crates/wake-core/src/adapters/codebuddy.rs b/crates/wake-core/src/adapters/codebuddy.rs
index 217a098..b5c9ee4 100644
--- a/crates/wake-core/src/adapters/codebuddy.rs
+++ b/crates/wake-core/src/adapters/codebuddy.rs
@@ -25,8 +25,7 @@ use std::path::{Path, PathBuf};
/// `<image_local_path>…`),CodeBuddy 自己的 getEffectiveSessionTitle 也跳过
/// 它们。模型取 providerData.requestModelName(人类可读)回退 model(id);
/// token 取 providerData.rawUsage(OpenAI completions 形)按调用累加。
-/// `file-history-snapshot` / `summary` / `turn-metrics` 是已知元数据行,表外
-/// 计 unknown。`CODEBUDDY_CONFIG_DIR` 覆盖数据根(与 Qoder 的 QODER_CONFIG_DIR
+/// 已知的元数据行见 `KNOWN_SKIP`,表外计 unknown。`CODEBUDDY_CONFIG_DIR` 覆盖数据根(与 Qoder 的 QODER_CONFIG_DIR
/// 同款:探到会话才采信)。
///
/// 格式来源:官方 CLI 文档 + 三家独立实现(cc-switch / codex-host / codeg)
@@ -67,8 +66,22 @@ impl CodebuddyAdapter {
}
}
-/// 已知的非消息行:静默跳过、不计 unknown。表外类型计数(漂移金丝雀)
-const KNOWN_SKIP: &[&str] = &["file-history-snapshot", "summary", "turn-metrics"];
+/// 已知的非消息行:静默跳过、不计 unknown。表外类型计数(漂移金丝雀)。照 CodeBuddy 2.167
+/// `isCustomInputItem` 的清单(标题行在解析循环里另处理)加它追加进转录的 `session-meta`
+/// 快照。`model-usage` 是用量没落到消息行上的那次调用的账,是否与消息行上的 rawUsage 互斥
+/// 从打包后的代码里判不准,先不计 token
+const KNOWN_SKIP: &[&str] = &[
+ "file-history-snapshot",
+ "summary",
+ "turn-metrics",
+ "goal-result",
+ "goal-progress",
+ "resend-fork-notice",
+ "acp-terminal-state",
+ "model-usage",
+ "credit-usage",
+ "session-meta",
+];
/// CodeBuddy 的 isGeneratedPlaceholderTitle:自动标题没东西可总结时写的占位,
/// 显示它比回退到首条用户消息更糟
diff --git a/crates/wake-core/tests/adapter_contracts.rs b/crates/wake-core/tests/adapter_contracts.rs
index 02fa08c..8b12e07 100644
--- a/crates/wake-core/tests/adapter_contracts.rs
+++ b/crates/wake-core/tests/adapter_contracts.rs
@@ -6693,7 +6693,8 @@ fn codebuddy_parse_contract() {
}
/// 没有 custom/ai 标题时退到 topic;reasoning 的 content.text 形也收进 thinking;
-/// 只有 model id 时就显示 id;rawUsage 缺 total_tokens 时按 prompt+completion 计
+/// 只有 model id 时就显示 id;rawUsage 缺 total_tokens 时按 prompt+completion 计。fixture 末尾的
+/// 新版非消息行(#66)都认得、不出消息,`model-usage` 的用量不计
#[test]
fn codebuddy_topic_title_and_model_id_fallback() {
let _env = setup();
diff --git a/crates/wake-core/tests/fixtures/codebuddy/projects/Users-fixture-src-wakefx/cb000002-aaaa-bbbb-cccc-000000000002.jsonl b/crates/wake-core/tests/fixtures/codebuddy/projects/Users-fixture-src-wakefx/cb000002-aaaa-bbbb-cccc-000000000002.jsonl
index 57046a0..32e4b4c 100644
--- a/crates/wake-core/tests/fixtures/codebuddy/projects/Users-fixture-src-wakefx/cb000002-aaaa-bbbb-cccc-000000000002.jsonl
+++ b/crates/wake-core/tests/fixtures/codebuddy/projects/Users-fixture-src-wakefx/cb000002-aaaa-bbbb-cccc-000000000002.jsonl
@@ -2,3 +2,10 @@
{"timestamp":1781100000100,"type":"topic","topic":"Weekly report draft","sessionId":"cb000002-aaaa-bbbb-cccc-000000000002"}
{"id":"n-0002","timestamp":1781100001000,"type":"reasoning","providerData":{"conversationRequestId":"req-1001","model":"hy3","agent":"cli"},"content":[{"type":"text","text":"Collect merged PRs first, then group by area."}],"sessionId":"cb000002-aaaa-bbbb-cccc-000000000002","cwd":"/Users/fixture/src/wakefx"}
{"id":"n-0003","timestamp":1781100001100,"type":"message","role":"assistant","providerData":{"conversationRequestId":"req-1001","model":"hy3","agent":"cli","rawUsage":{"prompt_tokens":900,"completion_tokens":120}},"status":"completed","content":[{"type":"text","text":"周报草稿如下:本周合并了 3 个 PR……"}],"sessionId":"cb000002-aaaa-bbbb-cccc-000000000002","cwd":"/Users/fixture/src/wakefx"}
+{"type":"goal-progress","id":"g-0001","condition":"report drafted","reason":"collecting PRs","turnCount":1,"createdAt":1781100000200}
+{"type":"goal-result","id":"g-0002","ok":true,"reason":"draft ready","condition":"report drafted","durationMs":1200,"turnCount":1,"tokenDelta":0}
+{"type":"model-usage","id":"u-0001","parentId":"n-0003","timestamp":1781100001150,"providerData":{"conversationRequestId":"req-1001","messageId":"msg-x","model":"hy3","rawUsage":{"prompt_tokens":5000,"completion_tokens":500},"usage":{"inputTokens":5000,"outputTokens":500}}}
+{"type":"credit-usage","id":"c-0001","parentId":"n-0003","timestamp":1781100001160,"providerData":{"credit":0.42}}
+{"type":"acp-terminal-state","id":"t-0001","parentId":"n-0003","timestamp":1781100001170,"requestId":"req-1001","rootRequestId":"req-1001","stopReason":"end_turn"}
+{"type":"resend-fork-notice","id":"f-0001","parentId":"n-0001","timestamp":1781100001180,"providerData":{"skipRun":true,"resendForkNotice":true}}
+{"type":"session-meta","id":"s-0001","sessionId":"cb000002-aaaa-bbbb-cccc-000000000002","timestamp":1781100001190,"meta":{"codebuddy.ai/hostKind":"cli"}}