All your AI agent sessions in one place — browse, search, resume. Rust + GPUI.
Rust
feat(codex): nest spawn_agent sub-agents under the session that spawned them
Corey Chiu9d67175415a2
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex f78346f..206fe65 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -2,6 +2,7 @@## [Unreleased]+- Update: Codex sub-agents started with `spawn_agent` are indexed again, nested under the session that spawned them and titled with their task name; the parent's conversation that Codex copies into each sub-agent is folded away so it is only indexed once. The guardian auto-review, `/review`, compaction and memory-consolidation threads stay excluded. In the MCP tools and `wake-cli`, a session now names its parent and lists its child sessions, for every agent that has them (#42, thanks @ShadowySpirits). Existing indexes are re-read once after upgrading- New: ZCode (Z.ai's GLM-5.3 desktop harness) sessions are indexed from its local database — titles, models, tool calls and token counts included. Forks and side chats are listed like any other conversation; sub-agent runs and conversations imported from Claude Code are left out so nothing appears twice. Read-only, and no Open In: the app has no command line to resume from## [0.7.0] — 2026-09-16diff --git a/PRODUCT.md b/PRODUCT.mdindex 4fb3aaf..5c301f2 100644--- a/PRODUCT.md+++ b/PRODUCT.md@@ -30,7 +30,7 @@ Corey 本人(独立开发者,主力工具 Claude Code 与 Codex,中文为主)。已实现:十九家 adapter、FTS5 trigram 搜索(<3 码点 LIKE 降级)、**搜索跳转定位**(2026-08-18:⌘K 命中直达详情页对应消息并高亮,seq 契约保证)、详情页逐消息渲染(气泡/工具折叠簇/thinking/tree-sitter 高亮;2026-08-17 由整篇 markdown 方案升级)、恢复/收藏/置顶/导出/删除(废纸篓+墓碑)、文件监听增量、Insights 统计页(0.3.0:活跃热力图与 streak、时段/星期/月份分布、Agents·Projects·Models 三榜单按 sessions/tokens/prompts 切换;2026-09-03 加 Last 7 days 周对比行与 Over time 近 53 周按 agent 堆叠的每周 prompts 趋势图;口径=主线用户消息,规格见 DESIGN.md)、Updates 页与 macOS Wake 菜单手动检查 GitHub 最新正式版并打开 Release 页更新(不后台联网、不自动替换应用包)、测试套件(adapter 契约、DB 往返、scanner 回归 + CI 三平台 + pre-commit,合成 fixture)、三端桌面(macOS 主平台;Linux/Windows experimental,终端恢复/废纸篓·回收站/剪贴板按平台原生实现,发版 CI 自动出六产物)、窗口记忆(0.3.6:记住所在屏幕/屏内位置/最大化/全屏,重启与 Dock 重开都回到原处,Settings 开在主窗所在屏)、完整 macOS 菜单栏(0.3.6:标准 Edit/Window 菜单、⌘W、Window → Main Window,主窗关闭后 About/Settings/Updates 仍可用)、导出 Markdown 与保存图片走系统「另存为」并记住上次目录(0.3.6,issue #25)、远程 host(0.4.0,issue #21:Settings → Remote hosts 配 SSH 目标,rsync 白名单镜像会话数据到本地缓存后与本地会话同列同搜,`@host` 徽章标识;阶段 1 只读——不动远端文件、远程会话禁删,resume 以 Copy SSH command 形态提供;分期计划见 CLAUDE.md「远程 host」节)、**MCP 接入**(0.5.0:随应用打包的只读 `wake-mcp` stdio server,四个工具 wake_search / wake_list_sessions / wake_get_session / wake_list_projects,Claude Code / Codex / Cursor 等任何 MCP 客户端可搜历史、按项目列会话、分页读转录;Settings → Connect 展示路径与可复制配置片段,只展示不代写别家配置;零 LLM、零网络、不写库;完整参考 docs/mcp.md)、**命令行与 Skill**(0.6.0:并排打包的只读 `wake-cli`,四个子命令 search / sessions / show / projects 加 setup,给"能跑 shell 但不说 MCP"的 agent 和真人用——它不新写查询逻辑,argv 翻成 JSON 喂同一批工具,输出与 MCP 客户端看到的**逐字节相同**(仅 CLI 末尾补一个换行)并由测试卡住,所以文档只需描述一份格式;`skills/wake/SKILL.md` 是可一行安装的 skill(`npx skills add iAmCorey/Wake`),用触发条件而非名词解释写 description,让 agent 自己想得起来去翻会话历史;完整参考 docs/cli.md;0.6.3 加 `wake-cli index`——装了 Wake 却从没启动过时,agent 自己跑一条就能把索引建起来继续干活,而不是停下来问人。它**只建不存在的索引**,已有的库原样交给 GUI:扫描落在旁边的临时库、扫完才原子占位,所以被中途杀掉可重试、撞上 GUI 首扫就退让)、Connect 页四区块(0.6.1:MCP server / MCP clients / Command line / Skill,每个面的第一块挂自己的文档链接)。后续边界(2026-09-07 定):摘要层(需 LLM、opt-in、明示会把会话正文发给用户配置的端点)只在 MCP 接入有真实使用之后再做;Timeline / Profile 一类视图建立在摘要之上;不做 ChatGPT / Claude.ai 导出导入主线、不做实体本体与知识图谱、不做 Chrome 扩展注入。约束:对 agent 数据目录只读;绝不写 Codex 的 SQLite;不读凭证;GPUI 无 SF Symbols(图标用 lucide SVG 自备)。-已支持十九家 agent:Claude Code、Codex(0.6.6 起排除可识别的内部线程:guardian auto-review、`/review`、compaction、memory consolidation、thread_spawn 子代理与用户会话同树,adapter 文件边界按首行 session_meta 的 source / thread_source 认出即不枚举;老格式或读不出的首行保守放行,`codex exec --thread-source` 打了标签的自动化线程照常收录,issue #30)、Qoder CLI(`~/.qoder/projects` JSONL,active-leaf 分支恢复、tool result 回挂、`QODER_CONFIG_DIR`)、Copilot CLI、Cursor(CLI 转录 + 0.6.7 起 IDE Chat/Composer 历史,PR #32:`globalStorage/state.vscdb` 明文 KV 库,composerData 给顺序、bubbleId 行给正文;转录带正文的会话归转录源,库只补转录缺失或只剩 turn_ended 空壳的会话;库里多数老会话没存工作区路径,落 Unknown project)、OpenCode(含 OpenCode 2 next,stable 的 `opencode.db` 与 next 的 `opencode-next.db` 同时扫描;逐会话兼容 `message+part`、真实 `session+session_message` 及早期 `session_v2` schema;preview 会话标 opencode2 徽章)、Kiro、Gemini CLI(2026-08-17 P1 五家落地)+ Pi、Oh My Pi、Grok Build、Kimi Code、Antigravity CLI(2026-08-19 对齐 kooky 内置 roster;Antigravity 正文加密仅元数据卡片)+ DeepSeek Harness(dsh,2026-08-20,zstd 事件日志透明解压;格式由源码推断,当天用户跑出真实会话完成首验)+ Hermes Agent(2026-09-03,多档案 state.db,无 cwd 故 project 留空)、OpenClaw(2026-09-03,两代存储同扫;本机零会话,格式由源码推断未经真机验证)、CodeBuddy(2026-09-14,issue #27:`~/.codebuddy/projects` 的 Responses 形 JSONL,custom / ai / topic 三级标题,`CODEBUDDY_CONFIG_DIR`;本机零会话,格式由官方 CLI 文档与三家第三方实现交叉推断、未经真机验证)、WorkBuddy(同日,CodeBuddy 的孪生实例:同一解析核心,`~/.workbuddy/projects`、`WORKBUDDY_CONFIG_DIR`;桌面 app 无 CLI,不提供 resume;同构只有 cc-switch 一家佐证)、ZCode(2026-09-21:Z.ai 的 GLM-5.3 官方 harness,桌面 app;运行时是 OpenCode 衍生物——`~/.zcode/cli/db/db.sqlite` 的 session/message/part 与 OpenCode v1 同形、part 解码复用,但 session 表没有 model/tokens 列故另起一家;`v2/tasks-index.sqlite` 只借 deleted / migration_source 两个过滤位;按 `task_type` 白名单只列 interactive / fork / selection_side_chat(subagent_child 等运行时会话不列);`semantics.transcriptVisibility == hidden` 与用户消息 `origin != real_user` 归 Meta、compact_summary 折成一条、字段缺席放行;`ZCODE_STORAGE_DIR`;桌面 app 无 CLI、`zcode://` 没有按会话打开的深链,不提供 resume;本机 3.14.0 真会话首验通过,同日开源(Apache-2.0)后语义全部按源码核对)。做不了的:Windsurf/Trae 加密,Amp/Factory(Droid)/Warp 云端无本地数据,Reasonix 本机零会话格式未实测。+已支持十九家 agent:Claude Code、Codex(0.6.6 起排除可识别的内部线程:guardian auto-review、`/review`、compaction、memory consolidation 与用户会话同树,adapter 文件边界按首行 session_meta 的 source / thread_source 认出即不枚举;老格式或读不出的首行保守放行,`codex exec --thread-source` 打了标签的自动化线程照常收录,issue #30。`spawn_agent` 子代理是其中唯一的例外,issue #42:那是用户自己派出去的活,收录后挂在派它的会话下面、以任务名为标题,fork 进来的父线程历史折成一条不入库的占位,父会话的对话不会被索引两遍)、Qoder CLI(`~/.qoder/projects` JSONL,active-leaf 分支恢复、tool result 回挂、`QODER_CONFIG_DIR`)、Copilot CLI、Cursor(CLI 转录 + 0.6.7 起 IDE Chat/Composer 历史,PR #32:`globalStorage/state.vscdb` 明文 KV 库,composerData 给顺序、bubbleId 行给正文;转录带正文的会话归转录源,库只补转录缺失或只剩 turn_ended 空壳的会话;库里多数老会话没存工作区路径,落 Unknown project)、OpenCode(含 OpenCode 2 next,stable 的 `opencode.db` 与 next 的 `opencode-next.db` 同时扫描;逐会话兼容 `message+part`、真实 `session+session_message` 及早期 `session_v2` schema;preview 会话标 opencode2 徽章)、Kiro、Gemini CLI(2026-08-17 P1 五家落地)+ Pi、Oh My Pi、Grok Build、Kimi Code、Antigravity CLI(2026-08-19 对齐 kooky 内置 roster;Antigravity 正文加密仅元数据卡片)+ DeepSeek Harness(dsh,2026-08-20,zstd 事件日志透明解压;格式由源码推断,当天用户跑出真实会话完成首验)+ Hermes Agent(2026-09-03,多档案 state.db,无 cwd 故 project 留空)、OpenClaw(2026-09-03,两代存储同扫;本机零会话,格式由源码推断未经真机验证)、CodeBuddy(2026-09-14,issue #27:`~/.codebuddy/projects` 的 Responses 形 JSONL,custom / ai / topic 三级标题,`CODEBUDDY_CONFIG_DIR`;本机零会话,格式由官方 CLI 文档与三家第三方实现交叉推断、未经真机验证)、WorkBuddy(同日,CodeBuddy 的孪生实例:同一解析核心,`~/.workbuddy/projects`、`WORKBUDDY_CONFIG_DIR`;桌面 app 无 CLI,不提供 resume;同构只有 cc-switch 一家佐证)、ZCode(2026-09-21:Z.ai 的 GLM-5.3 官方 harness,桌面 app;运行时是 OpenCode 衍生物——`~/.zcode/cli/db/db.sqlite` 的 session/message/part 与 OpenCode v1 同形、part 解码复用,但 session 表没有 model/tokens 列故另起一家;`v2/tasks-index.sqlite` 只借 deleted / migration_source 两个过滤位;按 `task_type` 白名单只列 interactive / fork / selection_side_chat(subagent_child 等运行时会话不列);`semantics.transcriptVisibility == hidden` 与用户消息 `origin != real_user` 归 Meta、compact_summary 折成一条、字段缺席放行;`ZCODE_STORAGE_DIR`;桌面 app 无 CLI、`zcode://` 没有按会话打开的深链,不提供 resume;本机 3.14.0 真会话首验通过,同日开源(Apache-2.0)后语义全部按源码核对)。做不了的:Windsurf/Trae 加密,Amp/Factory(Droid)/Warp 云端无本地数据,Reasonix 本机零会话格式未实测。## Brand Commitmentsdiff --git a/crates/wake-core/src/adapters/codex.rs b/crates/wake-core/src/adapters/codex.rsindex b8400b4..b6e0f9a 100644--- a/crates/wake-core/src/adapters/codex.rs+++ b/crates/wake-core/src/adapters/codex.rs@@ -18,6 +18,7 @@ pub struct CodexAdapter {state_db: PathBuf,scan_sessions: bool,scan_archived: bool,+ links_cache: MtimeCache<Vec<(String, String)>>,}impl CodexAdapter {@@ -34,6 +35,7 @@ impl CodexAdapter {state_db: root.join("state_5.sqlite"),scan_sessions: true,scan_archived: true,+ links_cache: MtimeCache::new(),}}}@@ -45,48 +47,110 @@ fn rollout_file_name(path: &str) -> &str {/// Codex 把它启动的**每一条**线程都写进同一棵 rollout 树:用户线程之外还有/// guardian auto-review、`/review`、compaction、memory consolidation 与-/// thread_spawn 子代理。它自家的历史只列交互来源(cli/vscode/atlas/chatgpt),-/// Wake 则把"非用户线程"整族挡在 adapter 文件边界——UI、FTS、MCP 共用同一份-/// 索引,不必各猜一次(issue #30)。+/// `spawn_agent` 子代理。它自家的历史只列交互来源(cli/vscode/atlas/chatgpt),+/// Wake 则在 adapter 文件边界上把这棵树分成三支——UI、FTS、MCP 共用同一份+/// 索引,不必各猜一次(issue #30、#42)。///-/// 判据只读首行 session_meta:`source` 是对象即结构化来源——`subagent` 的-/// review/compact/thread_spawn/memory_consolidation/other,`internal` 的-/// guardian/memory_consolidation——字符串来源(cli/vscode/exec/mcp/unknown/-/// 自定义)才是用户线程;`thread_source` 另认 subagent/guardian_review/-/// memory_consolidation 三个内部值(issue 里的过渡格式只带这个字段)。上游落盘-/// 时把 Internal(Guardian) 改写成 SubAgent(Other("guardian")),两套写法都要认。-/// `thread_source` 的其余值是 `codex exec --thread-source` 给自动化打的 Feature-/// 标签,走 exec 这条 Wake 本就展示的路,照常保留。首行读不出、不是 JSON 或-/// 不是 session_meta(2025 老格式)一律保守放行:半写入或未来格式不能让真实-/// 会话消失。review 子线程的结果本就经 `<user_action>` 注入父会话渲染;-/// thread_spawn 子代理转录暂不展示,日后可走 parent_links 挂回父会话。-fn is_internal_thread(path: &Path) -> bool {+/// 判据只读首行 session_meta。`source` 是对象即结构化来源:`subagent` 的+/// review/compact/memory_consolidation/other 与 `internal` 的+/// guardian/memory_consolidation 全是噪音,**只有 `subagent.thread_spawn`+/// 例外**——那是用户自己在会话里派出去的活,进索引,再由 `parent_links`+/// 挂回父线程(issue #42)。字符串来源(cli/vscode/exec/mcp/unknown/自定义)+/// 是普通用户线程;`thread_source` 另认 subagent/guardian_review/+/// memory_consolidation 三个内部值(issue #30 里的过渡格式只带这个字段),+/// 它分不出 thread_spawn 与噪音,保守归内部。上游落盘时把 Internal(Guardian)+/// 改写成 SubAgent(Other("guardian")),两套写法都要认。`thread_source` 的其余+/// 值是 `codex exec --thread-source` 给自动化打的 Feature 标签,走 exec 这条+/// Wake 本就展示的路,照常保留。首行读不出、不是 JSON 或不是 session_meta+/// (2025 老格式)一律保守放行:半写入或未来格式不能让真实会话消失。review+/// 子线程的结果本就经 `<user_action>` 注入父会话渲染。+enum ThreadKind {+ /// 交互来源,或判不出用途的首行:照常作为顶层会话+ User,+ /// 整族不进索引+ Internal,+ /// 进索引,但挂在父线程下。**resume 照给**:`codex resume <SESSION_ID>`+ /// 收任何记录在案的线程 id,子线程在 Codex 自己的 state DB 里就是一条+ /// 记录(它家 picker 另有 `--all` 才列全),所以不像 OpenClaw/Kiro 那样+ /// 返回 None。kooky 认不认这条 id 没在真机验过,而 `open kooky://…` 一律+ /// 退 0(不变量 7),那条路上的失败看不出来+ Spawned(SpawnMeta),+}++/// `source.subagent.thread_spawn` 里给子线程起的名字。标题只能从这里来——+/// 派活的 payload 是加密的,子线程自己没有任何可用的用户消息。父子关系+/// **不从这里取**:同一个对象里的 `parent_thread_id` 只有读过这个文件才知道,+/// 拿它当关系来源会让 `parent_links` 变成"本进程迄今扫过谁"的函数;关系统一+/// 问 state DB 的登记表(见 `parent_links`)+struct SpawnMeta {+ agent_path: String,+ agent_nickname: String,+}++impl SpawnMeta {+ fn from_value(value: &Value) -> Self {+ let text = |key: &str| optional_string(value.get(key)).unwrap_or_default();+ Self {+ agent_path: text("agent_path"),+ agent_nickname: text("agent_nickname"),+ }+ }++ /// 标题取用户在 `spawn_agent(task_name=…)` 里起的名字:`agent_path` 是+ /// `/root/<task_name>` 的路径形态,末段即任务名。缺了退回上游随机起的+ /// 昵称(agent_nickname),两者都没有才交回 UNTITLED+ fn title(&self) -> Option<String> {+ let task = self.agent_path.rsplit('/').next().unwrap_or_default();+ let pick = if task.is_empty() {+ &self.agent_nickname+ } else {+ task+ };+ (!pick.is_empty()).then(|| pick.to_string())+ }+}++fn read_thread_kind(path: &Path) -> ThreadKind {let Ok(file) = fs::File::open(path) else {- return false;+ return ThreadKind::User;};// payload 还带 base_instructions:实测首行中位数 18 KB、最大 49 KB// (2026-09-15),预留容量免得 read_line 反复倍增let mut first_line = String::with_capacity(1 << 16);if BufReader::new(file).read_line(&mut first_line).unwrap_or(0) == 0 {- return false;+ return ThreadKind::User;}let Ok(head) = serde_json::from_str::<SessionMetaHead>(&first_line) else {- return false;+ return ThreadKind::User;};if head.kind != "session_meta" {- return false;+ return ThreadKind::User;}let Some(payload) = head.payload else {- return false;+ return ThreadKind::User;};- payload.source.is_some_and(|source| source.is_object())- || matches!(- payload.thread_source.as_deref(),- Some("subagent" | "guardian_review" | "memory_consolidation")- )+ thread_kind(payload.source.as_ref(), payload.thread_source.as_deref())+}++/// 首行的两个键 → 线程身份。`read_thread_kind`(窄结构反序列化)与 `parse_rollout`+/// (整行 Value)都走这里,判据不可能分家+fn thread_kind(source: Option<&Value>, thread_source: Option<&str>) -> ThreadKind {+ if let Some(source) = source.filter(|source| source.is_object()) {+ return match source.pointer("/subagent/thread_spawn") {+ Some(spawn) => ThreadKind::Spawned(SpawnMeta::from_value(spawn)),+ None => ThreadKind::Internal,+ };+ }+ if matches!(+ thread_source,+ Some("subagent" | "guardian_review" | "memory_consolidation")+ ) {+ return ThreadKind::Internal;+ }+ ThreadKind::User}-/// `is_internal_thread` 只看的两个键。按窄结构反序列化,serde 跳过+/// `thread_kind` 只看的两个键。按窄结构反序列化,serde 跳过/// base_instructions 那几十 KB 而不是整棵 Value 建起来再丢——别换回 Value#[derive(Deserialize)]struct SessionMetaHead {@@ -196,6 +260,34 @@ fn read_threads(state_db: &Path) -> Option<Vec<ThreadRow>> {query(&ro.conn).ok()}+/// state DB 的 spawn 登记表(child → parent)。status 列("open"/…)不参与:+/// 任务跑没跑完不改变归属。+///+/// **`None` 与 `Some(空)` 是两件事**,调用方据此决定缓不缓存:没有 state DB、+/// 老库没有这张表 = 确定没有关系(`Some(空)`);库在但打不开、读到一半出错 =+/// 不知道(`None`)。混成一个值的后果是 `sync_parent_links` 把"读不出来"当成+/// "关系已解除",`replace_parent_links` 一句 `UPDATE … SET parent_key=''`+/// 把整家的父子关系清空,而错误答案还被按 mtime 戳缓存下来、不自愈+fn read_spawn_edges(state_db: &Path) -> Option<HashMap<String, String>> {+ if !state_db.is_file() {+ return Some(HashMap::new());+ }+ let ro = open_sqlite_ro(state_db, "codex")?;+ // 缺表时 prepare 就失败(no such table)——那是老库,不是读不出来+ let Ok(mut stmt) = ro+ .conn+ .prepare("SELECT child_thread_id, parent_thread_id FROM thread_spawn_edges")+ else {+ return Some(HashMap::new());+ };+ let rows = stmt+ .query_map([], |r| Ok((r.get::<_, String>(0)?, r.get::<_, String>(1)?)))+ .ok()?;+ // 逐行 Err(列类型变了、读到一半 SQLITE_BUSY)不能 flatten 掉:少几条边+ // 与"这几条边被删了"在下游无法区分,同样会解挂那几条子会话+ rows.collect::<rusqlite::Result<HashMap<_, _>>>().ok()+}+struct CodexParse {messages: Vec<TranscriptMessage>,cwd: String,@@ -208,6 +300,8 @@ struct CodexParse {created_at: i64,updated_at: i64,unknown_lines: u32,+ /// 非 None = 这是 `spawn_agent` 起的子线程+ spawn: Option<SpawnMeta>,}fn friendly_source(originator: &str) -> Option<String> {@@ -374,6 +468,11 @@ fn parse_rollout(path: &Path, decode_images: bool) -> Result<CodexParse> {let mut updated_at: i64 = 0;let mut unknown_lines: u32 = 0;let mut saw_session_meta = false;+ let mut spawn: Option<SpawnMeta> = None;+ // 子线程自己的历史从哪个 ordinal 开始(首行 session_meta 里的权威值)+ let mut history_start: Option<i64> = None;+ // 子线程里"父线程历史到此为止"的下标(messages / event_fallback 各一)+ let mut inherited: Option<(usize, usize)> = None;for line in reader.lines() {let Ok(line) = line else {@@ -399,6 +498,18 @@ fn parse_rollout(path: &Path, decode_images: bool) -> Result<CodexParse> {updated_at = ts;}}+ // fork 段的终点:Codex 在子线程首行写了 `subagent_history_start_ordinal`,+ // 这一行的 ordinal 追平它,后面才是子线程自己的活。权威值优先,信封+ // 判据(下面的 agent_message arm)只是它缺席时的兜底+ if let (Some(start), None, Some(_)) = (history_start, inherited, spawn.as_ref()) {+ if row+ .get("ordinal")+ .and_then(Value::as_i64)+ .is_some_and(|ordinal| ordinal >= start)+ {+ inherited = Some((messages.len(), event_fallback.len()));+ }+ }let typ = row.get("type").and_then(|v| v.as_str()).unwrap_or("");let Some(payload) = row.get("payload") else {if typ != "compacted" && typ != "world_state" {@@ -411,6 +522,17 @@ fn parse_rollout(path: &Path, decode_images: bool) -> Result<CodexParse> {"session_meta" => {if !saw_session_meta {saw_session_meta = true;+ // fork 进来的父线程历史第二行还有一条 session_meta(父自己的),+ // saw_session_meta 已经把它挡住了+ if let ThreadKind::Spawned(meta) = thread_kind(+ payload.get("source"),+ payload.get("thread_source").and_then(Value::as_str),+ ) {+ spawn = Some(meta);+ history_start = payload+ .get("subagent_history_start_ordinal")+ .and_then(Value::as_i64);+ }if let Some(c) = payload.get("cwd").and_then(|v| v.as_str()) {cwd = c.to_string();}@@ -496,9 +618,13 @@ fn parse_rollout(path: &Path, decode_images: bool) -> Result<CodexParse> {}if !parts.is_empty() {let thinking = clip(&parts.join("\n\n"), MAX_TOOL_IO).0;+ // 同 need_host:fork 段里的宿主待会儿会被 splice 掉+ let last_is_inherited =+ inherited.is_some_and(|(cut, _)| messages.len() <= cut);match messages.last_mut() {Some(last)- if last.role == Role::Assistant+ if !last_is_inherited+ && last.role == Role::Assistant&& last.text.is_empty()&& last.thinking.is_none() =>{@@ -550,10 +676,16 @@ fn parse_rollout(path: &Path, decode_images: bool) -> Result<CodexParse> {is_error: false,sidechain_ref: None,};- let need_host = !matches!(- messages.last(),- Some(m) if m.role == Role::Assistant && m.kind == MessageKind::Text- );+ // 末条消息落在 fork 段里(下标 < cut)时必须另起宿主:+ // collapse_inherited 会把那段整段 splice 掉,挂上去的+ // 工具调用与其输出会跟着消失+ let last_is_inherited =+ inherited.is_some_and(|(cut, _)| messages.len() <= cut);+ let need_host = last_is_inherited+ || !matches!(+ messages.last(),+ Some(m) if m.role == Role::Assistant && m.kind == MessageKind::Text+ );if need_host {messages.push(mk_msg(Role::Assistant, MessageKind::Text, "", ts));}@@ -578,6 +710,24 @@ fn parse_rollout(path: &Path, decode_images: bool) -> Result<CodexParse> {append_images_to_message_end(message, parsed.images);}}+ // 与下面 event_msg 块里的同名 arm 无关:那边是助手正文+ "agent_message" => {+ // 父线程派活/追加指令的信封(Payload 加密,只有抬头是+ // 明文)。首行没给 `subagent_history_start_ordinal` 时的+ // 兜底判据:第一条发给**本子线程**的信封之前的一切,是+ // spawn 时按 fork_turns 复制进来的父线程历史。认收件人+ // 而不是"第一条 agent_message":父线程在 fork 点之前派过+ // 别的子代理时,那些信封也在复制进来的这段里。+ // **agent_path 认不出来就一条都不折**——退回"第一条信封"+ // 正是这句要防的事,而多折一段会让父线程的话进两次 FTS+ if let (Some(meta), None) = (spawn.as_ref(), inherited) {+ let mine = meta.agent_path.as_str();+ let to = payload.get("recipient").and_then(Value::as_str);+ if !mine.is_empty() && to == Some(mine) {+ inherited = Some((messages.len(), event_fallback.len()));+ }+ }+ }_ => {}}}@@ -666,11 +816,21 @@ fn parse_rollout(path: &Path, decode_images: bool) -> Result<CodexParse> {ts,));}- "world_state" => {}+ // 子线程每收一次派活就有一行,内容只有 {"trigger_turn":true}+ "world_state" | "inter_agent_communication_metadata" => {}_ => unknown_lines += 1,}}+ // fork 段先折叠再判 has_real:折完只剩一条 Meta 的子线程要走得到+ // event_msg 回退,与普通会话同一条路。回退流只截断、**不留标记**——+ // 它一非空就会在 has_real 为假时被选中,一条标记足以把子线程自己的+ // response_item 整条流挤掉(只跑了工具、还没出正文的子代理正是这形态)+ if let Some((cut, cut_fallback)) = inherited {+ collapse_inherited(&mut messages, cut);+ event_fallback.drain(..cut_fallback.min(event_fallback.len()));+ }+// response_item 完全缺席的会话退回 event_msg 流let has_real = messages.iter()@@ -694,9 +854,37 @@ fn parse_rollout(path: &Path, decode_images: bool) -> Result<CodexParse> {created_at,updated_at,unknown_lines,+ spawn,})}+/// `spawn_agent` 的 `fork_turns` 会把父线程的历史逐条复制进子线程的 rollout+/// (实测 `fork_turns:"all"` 复制的是真实 message 行,不是打包成一条的+/// "Codex agent history" 块,`is_injected_user_content` 拦不住)。原样入库+/// 就是:子线程偷走父线程的标题、父线程每一轮在 FTS 里出现两次、Insights+/// 的 prompt 数翻倍。折成一条 Meta——Meta 不进 FTS、不算 message_count、+/// 不参与标题推导,GUI / 导出 / MCP 也都跳过它——留一条而不是整段删掉,+/// 是为了"这里原本有东西"不至于无声消失;内容本体就在上一层的父会话里。+fn collapse_inherited(messages: &mut Vec<TranscriptMessage>, cut: usize) {+ if cut == 0 {+ return;+ }+ let turns = messages[..cut]+ .iter()+ .filter(|m| m.kind == MessageKind::Text)+ .count();+ let ts = messages[..cut]+ .iter()+ .find_map(|m| m.timestamp)+ .unwrap_or_default();+ let text = format!(+ "── {turns} message{} inherited from the parent thread ──",+ crate::text::plural(turns as i64)+ );+ let marker = mk_msg(Role::System, MessageKind::Meta, &text, ts);+ messages.splice(..cut, std::iter::once(marker));+}+/// Codex Desktop 会把文件清单包在真实提问外面,并在正文写入指向临时文件/// 的 `<image ...>` 标签;图片本体由独立内容块承载。fn clean_user_text(text: &str) -> String {@@ -734,7 +922,15 @@ pub(crate) fn rollout_native_id(stem: &str) -> String {}fn build_meta(r: &SessionFileRef, p: &CodexParse, archived_dir: &Path) -> SessionMeta {- let title = title_from_messages(&p.messages).unwrap_or_else(|| UNTITLED.to_string());+ // 子线程优先用任务名:它自己没有用户消息(派活加密),而 fork 段万一没折成+ // (整个文件里找不到派活信封)推导出来的会是父线程的首条消息。用户在 Codex+ // 里手动命名过的话,merge_quick_meta 仍会用 state DB 的 name 盖过这里+ let title = p+ .spawn+ .as_ref()+ .and_then(SpawnMeta::title)+ .or_else(|| title_from_messages(&p.messages))+ .unwrap_or_else(|| UNTITLED.to_string());let project_name = project_name_of(&p.cwd);SessionMeta {key: format!("codex:{}", r.native_id),@@ -807,12 +1003,23 @@ impl AgentAdapter for CodexAdapter {let Some(row) = by_name.get(rollout_file_name(&r.file_path)) else {continue;};+ // 结构化 source(对象)= 子代理线程。它的 `title` 是 Codex 按首条+ // 消息自动生成的,而子线程开头是 fork 进来的父线程对话——用它会让+ // 子会话又变成父会话标题的副本(0.6.6 修掉的那个症状)。这类行只+ // 认用户手工命名的 `name`,其余交回解析侧合成的任务名+ let auto_title_is_parents = row+ .source+ .as_deref()+ .is_some_and(|source| source.trim_start().starts_with('{'));let title = row.name.as_deref().filter(|n| !n.trim().is_empty()).map(String::from).or_else(|| {+ if auto_title_is_parents {+ return None;+ }// Codex 自家 state DB 会把注入文本存进 title,同样要过滤if is_injected_user_content(&row.title) {return None;@@ -856,13 +1063,45 @@ impl AgentAdapter for CodexAdapter {fn file_ref(&self, path: &Path) -> Option<SessionFileRef> {let mut r = default_file_ref(self.agent(), path)?;- if is_internal_thread(path) {+ if matches!(read_thread_kind(path), ThreadKind::Internal) {return None;}r.native_id = rollout_native_id(&r.native_id);Some(r)}+ fn manages_parent_links(&self) -> bool {+ true+ }++ /// 只认 state DB 的登记表,按库+WAL 的 mtime 戳缓存(cursor_ide 同款)。+ /// trait 说这是"当前数据根内的全量快照",所以只能问磁盘——边扫边记会让它+ /// 变成"本进程扫到哪了"的函数,半截快照会被 `sync_parent_links` 当成+ /// "关系已解除",把子会话连同继承来的项目一起打回原形,下一轮全量再挂回去,+ /// 来回抖;而按戳缓存是照实答、只是省掉重复的库打开:`sync_parent_links`+ /// 问的是**所有**管关系的 adapter,别家 watcher 事件也会走到这里。+ /// 代价:没有 state DB 的根(自定义 location 只选了数据目录的裸 rollout+ /// 拷贝)认不出父子,子线程以任务名作为顶层会话列出——不是噪音,只是没嵌套+ fn parent_links(&self) -> Vec<(String, String)> {+ let stamp = super::sqlite_ro::db_cache_stamp(&self.state_db);+ self.links_cache+ .get_or_try_build(stamp, || {+ // `?` 而不是 unwrap_or_default:读不出来时交回 None,MtimeCache+ // 于是不缓存,下次重试——把失败缓存成"没有关系"会让+ // sync_parent_links 当成"关系全解除",一句整家清空把所有子会话+ // 解挂,而且戳不动就不自愈+ let mut links: Vec<(String, String)> = read_spawn_edges(&self.state_db)?+ .into_iter()+ .filter(|(child, parent)| !parent.is_empty() && child != parent)+ .map(|(child, parent)| (format!("codex:{child}"), format!("codex:{parent}")))+ .collect();+ // HashMap 的迭代序是每进程随机的,别让它漏进返回值+ links.sort();+ Some(links)+ })+ .unwrap_or_default()+ }+fn merge_quick_meta(&self, mut parsed: SessionMeta, quick: &SessionMeta) -> SessionMeta {// state DB 的 title/name 是用户在 Codex 里手动命名,优先于首条消息推导;// UNTITLED 守卫防止占位符覆盖真实标题。key/id 以 state 的线程 id 为准。@@ -929,6 +1168,7 @@ impl AgentAdapter for CodexAdapter {state_db: dir.join("state_5.sqlite"),scan_sessions: true,scan_archived: true,+ links_cache: MtimeCache::new(),})}@@ -950,6 +1190,7 @@ impl AgentAdapter for CodexAdapter {state_db: self.state_db.clone(),scan_sessions: self.scan_sessions && !roots.contains(&self.sessions_dir),scan_archived: self.scan_archived && !roots.contains(&self.archived_dir),+ links_cache: MtimeCache::new(),}))}}diff --git a/crates/wake-core/src/db.rs b/crates/wake-core/src/db.rsindex 111d62b..3f68fc3 100644--- a/crates/wake-core/src/db.rs+++ b/crates/wake-core/src/db.rs@@ -135,7 +135,7 @@ CREATE VIRTUAL TABLE IF NOT EXISTS titles_fts USING fts5(/// "1" = 2026-09-14 前(工具段不过滤 Wake 自指),"2" = 过滤自指回声,/// "3" = Pi / omp / OpenClaw 累计每次 assistant 调用的 token,/// "4" = Cursor 项目路径优先读取工作区元数据,并恢复 slug 中的空格。-pub const FTS_FORMAT: &str = "4";+pub const FTS_FORMAT: &str = "5";fn open_conn(path: &Path) -> Result<Connection> {if let Some(dir) = path.parent() {@@ -1300,11 +1300,8 @@ impl Store {pub fn parent_key_of(&self, key: &str) -> Result<Option<String>> {let conn = self.read.lock().unwrap();let value: Option<String> = conn- .query_row(- "SELECT NULLIF(parent_key, '') FROM sessions WHERE key = ?1",- params![key],- |row| row.get(0),- )+ .prepare_cached("SELECT NULLIF(parent_key, '') FROM sessions WHERE key = ?1")?+ .query_row(params![key], |row| row.get(0)).optional()?.flatten();Ok(value)diff --git a/crates/wake-core/src/mcp/tools.rs b/crates/wake-core/src/mcp/tools.rsindex a1ff0a1..22c09dd 100644--- a/crates/wake-core/src/mcp/tools.rs+++ b/crates/wake-core/src/mcp/tools.rs@@ -743,6 +743,57 @@ fn find_session(store: &Store, key: &str) -> Result<Result<SessionMeta, String>,/// 主线页脚最多列多少个子代理转录;再多就 "… and N more"(Task 开得多的会话有上百个)const MAX_SUBAGENTS_LISTED: usize = 30;+/// 子会话页脚的同款预算(与上面那个各自独立:一条会话可以既有子会话又有+/// 侧边转录,两张清单不共享额度)+const MAX_CHILDREN_LISTED: usize = 30;++/// 挂在这条会话下面的子会话。它们是完整会话(各有 key、各自可分页读),+/// 但 `wake_list_sessions` 只给根(roots_only),所以父会话是唯一的发现+/// 入口——Codex 的 `spawn_agent` 子代理、Grok 的子会话都走这里。+/// 与侧边的 subagent 转录不是一回事:那些没有自己的 key,按 id 读+fn child_sessions(ctx: &ToolContext, parent_key: &str) -> Vec<SessionMeta> {+ // 字段全列、不带 ..Default:新增筛选字段时这里必须表态(与 workbench+ // current_filter 同一约定)。list_children 不在 SQL 里限量,上限在下面截+ ctx.store+ .list_children(+ parent_key,+ &SessionFilter {+ agents: Vec::new(),+ favorite_only: false,+ include_archived: false,+ roots_only: false,+ title_query: None,+ sort: SortKey::Updated,+ ascending: false,+ limit: 0,+ offset: 0,+ updated_since: None,+ project_paths: Vec::new(),+ ignore_pins: true,+ },+ )+ .unwrap_or_default()+}++fn child_lines(children: &[SessionMeta]) -> String {+ let mut out = String::new();+ for child in children.iter().take(MAX_CHILDREN_LISTED) {+ out.push_str(&format!(+ "- `{}` — \"{}\" · {} message{}\n",+ child.key,+ one_line(&child.title, 120),+ child.message_count,+ plural(child.message_count)+ ));+ }+ if children.len() > MAX_CHILDREN_LISTED {+ out.push_str(&format!(+ "- … and {} more\n",+ children.len() - MAX_CHILDREN_LISTED+ ));+ }+ out+}/// `agent-a1b2 — Explore: find the watcher code`;没有边车信息时只有 idfn subagent_label(sc: &SidechainInfo) -> String {@@ -894,6 +945,11 @@ fn get_session(ctx: &ToolContext, args: &Value) -> ToolResult {if !meta.host.is_empty() {facts.push(format!("host: @{}", meta.host));}+ // 子会话给出回父会话的路:它自己不在 wake_list_sessions 的结果里,+ // 读者多半是顺着搜索命中落进来的,得知道上下文挂在哪+ if let Ok(Some(parent)) = ctx.store.parent_key_of(&meta.key) {+ facts.push(format!("parent: `{parent}`"));+ }if let Some((info, _)) = &sidechain {facts.push(format!("subagent: {}", subagent_label(info)));}@@ -936,6 +992,26 @@ fn get_session(ctx: &ToolContext, args: &Value) -> ToolResult {out.push_str(&facts.join(" · "));out.push_str("\n\n");+ // 子会话页脚在空页上也得给:`wake_list_sessions` 只回根会话,父会话是+ // 它们唯一的发现入口,而"这一页什么都没渲染"(整条都是 Meta、from_seq+ // 翻过了尾)与"没有子会话"是两回事+ let children = if sub_id.is_none() {+ child_sessions(ctx, &meta.key)+ } else {+ Vec::new()+ };+ let children_footer = |out: &mut String| {+ if children.is_empty() {+ return;+ }+ out.push_str(&format!(+ "{} child session{} (read one with {GET_SESSION} using its key):\n{}",+ children.len(),+ plural(children.len() as i64),+ child_lines(&children)+ ));+ };+if page.rendered == 0 {out.push_str(&match last_seq {Some(last) => format!(@@ -943,6 +1019,7 @@ fn get_session(ctx: &ToolContext, args: &Value) -> ToolResult {),None => "This transcript has no messages.\n".to_string(),});+ children_footer(&mut out);return Ok(out);}out.push_str(&page.text);@@ -965,14 +1042,18 @@ fn get_session(ctx: &ToolContext, args: &Value) -> ToolResult {}out.push_str(&summary);out.push_str(".\n");- // 主线页脚列出子代理转录:它们不并进主线(各有自己的 seq),按 id 单独读- if sub_id.is_none() && !transcript.sidechains.is_empty() {- out.push_str(&format!(- "{} subagent transcript{} (pass an id as `subagent` to read one):\n{}",- transcript.sidechains.len(),- plural(transcript.sidechains.len() as i64),- subagent_lines(&transcript.sidechains, Some(MAX_SUBAGENTS_LISTED))- ));+ // 主线页脚两张清单:挂在这条会话下面的子会话(有自己的 key,按 key 读),+ // 与侧边的子代理转录(不并进主线、各有自己的 seq,按 id 读)+ children_footer(&mut out);+ if sub_id.is_none() {+ if !transcript.sidechains.is_empty() {+ out.push_str(&format!(+ "{} subagent transcript{} (pass an id as `subagent` to read one):\n{}",+ transcript.sidechains.len(),+ plural(transcript.sidechains.len() as i64),+ subagent_lines(&transcript.sidechains, Some(MAX_SUBAGENTS_LISTED))+ ));+ }}let with_sub = sub_id.map(|id| format!("subagent=\"{id}\" and "))diff --git a/crates/wake-core/src/scanner.rs b/crates/wake-core/src/scanner.rsindex 8568ff4..32ee9cf 100644--- a/crates/wake-core/src/scanner.rs+++ b/crates/wake-core/src/scanner.rs@@ -498,6 +498,19 @@ fn sync_parent_links(adapters: &[Box<dyn AgentAdapter>], store: &Arc<Store>) ->let mut changed = false;for agent in managed_agents {+ // 这一家眼下一条关系都没有、库里也没有:整段对账是纯浪费——+ // session_sources_for_agent 要把这家全部会话读一遍,replace_parent_links+ // 还要开写事务与扫描线程抢锁。watcher 只要**任一**受影响 agent 管关系+ // 就会走到这里,而多数 agent 常年零关系(Codex 是 spawn_agent 用过才有)+ let current = store.parent_links_for_agent(agent)?;+ let has_links = links_by_adapter+ .iter()+ .enumerate()+ .any(|(ix, links)| adapters[ix].agent() == agent && !links.is_empty());+ if !has_links && current.is_empty() {+ continue;+ }+let sources = store.session_sources_for_agent(agent)?;let mut source_by_key = std::collections::HashMap::new();let mut owner_by_key = std::collections::HashMap::new();@@ -523,6 +536,25 @@ fn sync_parent_links(adapters: &[Box<dyn AgentAdapter>], store: &Arc<Store>) ->}}}+ // 上面那条"报边的实例必须拥有 parent"是照 Grok 写的:它的边车长在+ // parent 自己的 location 里,报边者天然就是拥有者。Codex 的+ // thread_spawn_edges 是 home 的一张总表,parent 的胜出文件完全可能+ // 归另一个同家实例(用户给某个备份目录加了 location)。所以补一轮:+ // 上一轮没认领的 child,只要 parent 确实在库里就接受——先来后到按+ // roster 顺序,权威那一轮的结论不会被这一轮盖掉+ for (adapter_ix, links) in links_by_adapter.iter().enumerate() {+ if adapters[adapter_ix].agent() != agent {+ continue;+ }+ for (child, parent) in links {+ if source_by_key.contains_key(child)+ && owner_by_key.contains_key(parent)+ && !direct.contains_key(child)+ {+ direct.insert(child.clone(), parent.clone());+ }+ }+ }// 各 location 只能看见自己的直接/局部链;合并后再走到全局 root。let mut desired_map = std::collections::HashMap::new();@@ -532,14 +564,35 @@ fn sync_parent_links(adapters: &[Box<dyn AgentAdapter>], store: &Arc<Store>) ->}}+ // 仍被 adapter 声称的关系,不算"已解除"。parent 行这一刻不在库里是+ // 常态:watcher 的增量不走 SCAN_GATE,与全量扫描并发,一批事件很可能+ // 在 parent 写进库之前就读了 sources 快照。少了这道判断,这一批会拿+ // replace_parent_links 的整家清空把全量刚建好的关系抹掉,而 Codex 没有+ // is_parent_link_event、state DB 也不在监听路径里,没有第二次机会补救+ let asserted: std::collections::HashSet<(&str, &str)> = links_by_adapter+ .iter()+ .enumerate()+ .filter(|(adapter_ix, _)| adapters[*adapter_ix].agent() == agent)+ .flat_map(|(_, links)| {+ links+ .iter()+ .map(|(child, parent)| (child.as_str(), parent.as_str()))+ })+ .collect();+// replace_parent_links 会把关系内 child 的 project 覆写成父项目。关系// 解除或换父时,先从 child 自己的胜出文件重解析,恢复 fallback project;// 解析失败则保留仍有效的旧关系,下一次 Grok 事件继续重试。- let current = store.parent_links_for_agent(agent)?;for (child, old_parent) in current {if desired_map.get(&child) == Some(&old_parent) {continue;}+ // 保留不会留下悬空关系:replace_parent_links 的 UPDATE 带+ // EXISTS(parent),parent 真没了这条边写不进去+ if asserted.contains(&(child.as_str(), old_parent.as_str())) {+ desired_map.insert(child, old_parent);+ continue;+ }let restored = source_by_key.get(&child).is_some_and(|file_path| {reparse_for_parent_change(adapters, store, agent, &child, file_path)});diff --git a/crates/wake-core/tests/adapter_contracts.rs b/crates/wake-core/tests/adapter_contracts.rsindex 2b425de..f221d08 100644--- a/crates/wake-core/tests/adapter_contracts.rs+++ b/crates/wake-core/tests/adapter_contracts.rs@@ -579,8 +579,9 @@ fn codex_internal_threads_are_excluded_at_the_file_boundary() {let spawn = serde_json::json!({"parent_thread_id": id(99), "depth": 1, "agent_path": "/root/research"});- // 隐藏的那组是上游各种落盘形态的抽样:`source` 是对象这一条就够判,列全是- // 为了谁把它收窄成按路径取值(pointer("/source/subagent/other"))时立刻红+ // 对象来源默认即噪音,唯一的例外是 `subagent.thread_spawn`(issue #42)。+ // 列全上游各种落盘形态,是为了谁把默认那一侧从"除 thread_spawn 外全挡"+ // 收窄成白名单(只认 review/compact 几个词)时立刻红let cases = [// guardian auto-review:早期写端 thread_source 仍是 subagent;只带对象;// issue #30 的过渡格式只带 thread_source;字符串来源 + thread_source=subagent@@ -588,15 +589,16 @@ fn codex_internal_threads_are_excluded_at_the_file_boundary() {(meta(2, serde_json::json!({"source": {"subagent": {"other": "guardian"}}})), false),(meta(3, serde_json::json!({"source": "cli", "thread_source": "guardian_review"})), false),(meta(4, serde_json::json!({"source": "exec", "thread_source": "subagent"})), false),- // `/review`、compaction、thread_spawn 子代理+ // `/review`、compaction(meta(5, serde_json::json!({"source": {"subagent": "review"}, "thread_source": "subagent"})), false),(meta(6, serde_json::json!({"source": {"subagent": "compact"}, "thread_source": "subagent"})), false),- (meta(7, serde_json::json!({"parent_thread_id": id(99), "source": {"subagent": {"thread_spawn": spawn}}, "thread_source": "subagent"})), false),// memory consolidation 的 subagent / internal 两种写法;上游今天落盘前会把// Internal(Guardian) 改写成 subagent/other,哪天不改写了也要认(meta(8, serde_json::json!({"source": {"subagent": "memory_consolidation"}})), false),(meta(9, serde_json::json!({"source": {"internal": "memory_consolidation"}, "thread_source": "memory_consolidation"})), false),(meta(10, serde_json::json!({"source": {"internal": "guardian"}, "thread_source": "guardian_review"})), false),+ // `spawn_agent` 子代理:同样是 subagent/对象来源,但它是用户自己派的活+ (meta(7, serde_json::json!({"source": {"subagent": {"thread_spawn": spawn}}, "thread_source": "subagent"})), true),// 用户线程:字符串来源的各种写法,含 `codex exec --thread-source` 的 Feature 标签(meta(11, serde_json::json!({"source": "vscode", "thread_source": "user"})), true),(meta(12, serde_json::json!({"source": "exec"})), true),@@ -658,6 +660,283 @@ fn codex_internal_threads_are_excluded_at_the_file_boundary() {assert_eq!(actual, expected, "full scan must use the same boundary");}+/// `spawn_agent` 子代理进索引(issue #42),但 `fork_turns` 复制进来的父线程+/// 历史必须整段折掉:原样入库就是子线程偷走父线程的标题、父线程每一轮在+/// FTS 里出现两次、Insights 的 prompt 数翻倍。分界点认首行的+/// `subagent_history_start_ordinal`,子线程自己的工具调用必须活下来——折叠是+/// 按下标 splice 的,而工具调用默认挂在"最后一条助手消息"上,fork 段以助手+/// 消息收尾时那一条正在待删区里+#[test]+fn codex_spawned_subagent_keeps_only_its_own_turns() {+ setup();+ let home = tempfile::tempdir().unwrap();+ let (parent_id, child_id, _) = common::stage_codex_spawn_pair(home.path());+ let adapter = CodexAdapter::new().with_custom_root(home.path().to_path_buf());++ let refs = adapter.list_session_files().unwrap();+ let ids: HashSet<String> = refs.iter().map(|r| r.native_id.clone()).collect();+ assert_eq!(+ ids,+ HashSet::from([parent_id.clone(), child_id.clone()]),+ "子代理必须与父线程一起进索引"+ );++ let child = refs.iter().find(|r| r.native_id == child_id).unwrap();+ let parsed = adapter.parse_session(child).unwrap();+ assert_eq!(+ parsed.meta.title, "review_issue17",+ "标题取 spawn_agent 的任务名:子线程自己没有用户消息"+ );++ let transcript = adapter.parse_transcript(child).unwrap();+ let visible: Vec<&TranscriptMessage> = transcript+ .mainline+ .iter()+ .filter(|m| m.kind != MessageKind::Meta)+ .collect();+ let text: String = visible+ .iter()+ .map(|m| m.text.as_str())+ .collect::<Vec<_>>()+ .join("\n");+ assert!(+ !text.contains("inherited"),+ "fork 段整段折成一条 Meta:{text}"+ );+ assert!(text.contains("child found the missing dependency array"));+ let tools: Vec<&ToolCallView> = visible.iter().flat_map(|m| &m.tool_calls).collect();+ assert_eq!(+ tools.len(),+ 1,+ "子线程自己的工具调用不得随 fork 段一起被删掉"+ );+ assert_eq!(tools[0].output.as_deref(), Some("CHILD_TOOL_OUTPUT"));++ let indexed: String = parsed+ .units+ .iter()+ .map(|u| u.text.as_str())+ .collect::<Vec<_>>()+ .join("\n");+ assert!(+ !indexed.contains("inherited"),+ "父线程的话不得在子线程里再进一次 FTS:{indexed}"+ );+ // seq 契约:两侧解析器同源,FTS 单元的 seq 必须等于详情页的消息序号+ assert_eq!(parsed.units[0].seq, visible[0].seq);++ assert_eq!(+ adapter.parent_links(),+ vec![(format!("codex:{child_id}"), format!("codex:{parent_id}"))]+ );+}++/// 首行没写 `subagent_history_start_ordinal`(老写端)时退回派活信封,并且+/// **认收件人**:fork 段里那封发给 `/root/other_task` 的信不算数+#[test]+fn codex_spawn_cut_falls_back_to_the_dispatch_envelope() {+ setup();+ let home = tempfile::tempdir().unwrap();+ let (_, child_id, child_path) = common::stage_codex_spawn_pair(home.path());+ strip_history_ordinal(&child_path);++ let adapter = CodexAdapter::new().with_custom_root(home.path().to_path_buf());+ let refs = adapter.list_session_files().unwrap();+ let child = refs.iter().find(|r| r.native_id == child_id).unwrap();+ let parsed = adapter.parse_session(child).unwrap();+ assert_eq!(parsed.meta.title, "review_issue17");+ let indexed: String = parsed+ .units+ .iter()+ .map(|u| u.text.as_str())+ .collect::<Vec<_>>()+ .join("\n");+ assert!(!indexed.contains("inherited"), "{indexed}");+ assert!(indexed.contains("child found the missing dependency array"));+}++/// 既没有权威 ordinal、又认不出发给自己的信封(半写入、未来格式、agent_path+/// 缺失)就**一条都不折**:内容多一份好过凭空消失,与"首行判不出用途一律保守+/// 放行"同一取舍。退回"第一条信封"才是要防的事——那会在 fork 段中间切一刀+#[test]+fn codex_spawn_without_a_usable_cut_keeps_everything() {+ setup();+ for blank_agent_path in [false, true] {+ let home = tempfile::tempdir().unwrap();+ let (_, child_id, child_path) = common::stage_codex_spawn_pair(home.path());+ let mut head = strip_history_ordinal(&child_path);+ if blank_agent_path {+ // agent_path 认不出来:不得退化成"第一条 agent_message 就是分界"+ head["payload"]["source"]["subagent"]["thread_spawn"]+ .as_object_mut()+ .unwrap()+ .remove("agent_path");+ head["payload"]+ .as_object_mut()+ .unwrap()+ .remove("agent_path");+ } else {+ // 信封整行不见了,但子线程首行还在,它仍然是子代理+ let rest = fs::read_to_string(&child_path).unwrap();+ let kept: String = rest+ .lines()+ .filter(|line| !line.contains("\"recipient\":\"/root/review_issue17\""))+ .map(|line| format!("{line}\n"))+ .collect();+ fs::write(&child_path, kept).unwrap();+ }+ if blank_agent_path {+ rewrite_head(&child_path, &head);+ }++ let adapter = CodexAdapter::new().with_custom_root(home.path().to_path_buf());+ let refs = adapter.list_session_files().unwrap();+ let child = refs.iter().find(|r| r.native_id == child_id).unwrap();+ let parsed = adapter.parse_session(child).unwrap();+ let indexed: String = parsed+ .units+ .iter()+ .map(|u| u.text.as_str())+ .collect::<Vec<_>>()+ .join("\n");+ assert!(+ indexed.contains("inherited parent turn") && indexed.contains("missing dependency"),+ "blank_agent_path={blank_agent_path}: {indexed}"+ );+ // 仍然认得出是子代理,所以标题还是任务名(agent_path 抹掉那次退昵称)+ let expected = if blank_agent_path {+ "Wegener"+ } else {+ "review_issue17"+ };+ assert_eq!(+ parsed.meta.title, expected,+ "blank_agent_path={blank_agent_path}"+ );+ }+}++/// 只跑了工具、还没出正文的子代理:`has_real` 为假,折叠若在 event_fallback+/// 里留下标记,那条标记会把子线程自己的 response_item 整条流挤掉+#[test]+fn codex_running_subagent_keeps_its_tool_calls_over_the_event_stream() {+ setup();+ let home = tempfile::tempdir().unwrap();+ let (_, child_id, child_path) = common::stage_codex_spawn_pair(home.path());+ // 权威 ordinal 去掉,改由信封定界(下面要往 fork 段里插行,插了 ordinal 就+ // 对不上了);fork 段补一条 event_msg 让 event_fallback 非空,子线程自己+ // 那段只留工具调用(删掉它的助手正文)+ strip_history_ordinal(&child_path);+ let event = serde_json::json!({+ "timestamp": "2026-09-16T09:05:00.000Z",+ "type": "event_msg",+ "payload": {"type": "user_message", "message": "inherited parent turn about the qr login bug"}+ });+ let mut kept: Vec<String> = Vec::new();+ for line in fs::read_to_string(&child_path).unwrap().lines() {+ if line.contains("child found the missing dependency array") {+ continue;+ }+ if line.contains("\"recipient\":\"/root/review_issue17\"") {+ kept.push(event.to_string());+ }+ kept.push(line.to_string());+ }+ fs::write(+ &child_path,+ kept.iter().map(|l| format!("{l}\n")).collect::<String>(),+ )+ .unwrap();++ let adapter = CodexAdapter::new().with_custom_root(home.path().to_path_buf());+ let refs = adapter.list_session_files().unwrap();+ let child = refs.iter().find(|r| r.native_id == child_id).unwrap();+ let transcript = adapter.parse_transcript(child).unwrap();+ let tools: Vec<&ToolCallView> = transcript+ .mainline+ .iter()+ .flat_map(|m| &m.tool_calls)+ .collect();+ assert_eq!(tools.len(), 1, "{:#?}", transcript.mainline);+ assert_eq!(tools[0].output.as_deref(), Some("CHILD_TOOL_OUTPUT"));+}++/// 父子关系只认 state DB 的 thread_spawn_edges——它与 quick_meta 的 key 同一+/// id 空间,而且每次都是现问磁盘,不受"本进程扫到哪了"影响。代价写在这里:+/// 没有 state DB 的根认不出关系,子线程降级成带任务名的顶层会话,不是 Untitled+#[test]+fn codex_spawn_links_need_the_state_db_registry() {+ setup();+ let home = tempfile::tempdir().unwrap();+ let (_, child_id, _) = common::stage_codex_spawn_pair(home.path());+ fs::remove_file(home.path().join("state_5.sqlite")).unwrap();++ let adapter = CodexAdapter::new().with_custom_root(home.path().to_path_buf());+ let refs = adapter.list_session_files().unwrap();+ assert!(adapter.parent_links().is_empty());+ let child = refs.iter().find(|r| r.native_id == child_id).unwrap();+ assert_eq!(+ adapter.parse_session(child).unwrap().meta.title,+ "review_issue17"+ );+}++/// 子代理线程的 state 行没有手工命名时,Codex 自动生成的 title 是按 fork 进来+/// 的父线程对话编的,不能拿它盖掉任务名(0.6.6 修掉的"标题是父会话的副本")+#[test]+fn codex_spawn_title_survives_codex_auto_title() {+ setup();+ let home = tempfile::tempdir().unwrap();+ let (_, child_id, _) = common::stage_codex_spawn_pair(home.path());+ let conn = rusqlite::Connection::open(home.path().join("state_5.sqlite")).unwrap();+ conn.execute(+ "UPDATE threads SET title = 'inherited parent turn about the qr login bug' WHERE id = ?1",+ rusqlite::params![child_id],+ )+ .unwrap();+ drop(conn);++ let adapter = CodexAdapter::new().with_custom_root(home.path().to_path_buf());+ let refs = adapter.list_session_files().unwrap();+ let child = refs.iter().find(|r| r.native_id == child_id).unwrap();+ let quick = adapter.quick_meta(&refs).expect("state db readable");+ let parsed = adapter.parse_session(child).unwrap();+ let merged = adapter.merge_quick_meta(parsed.meta, quick.get(&child.file_path).unwrap());+ assert_eq!(merged.title, "review_issue17");++ // 用户手工命名(name 列)仍然说了算+ let conn = rusqlite::Connection::open(home.path().join("state_5.sqlite")).unwrap();+ conn.execute(+ "UPDATE threads SET name = 'Renamed by user' WHERE id = ?1",+ rusqlite::params![child_id],+ )+ .unwrap();+ drop(conn);+ let quick = adapter.quick_meta(&refs).unwrap();+ let parsed = adapter.parse_session(child).unwrap();+ let merged = adapter.merge_quick_meta(parsed.meta, quick.get(&child.file_path).unwrap());+ assert_eq!(merged.title, "Renamed by user");+}++/// 子线程首行:去掉权威 ordinal,返回改过的首行 JSON 供调用方继续改+fn strip_history_ordinal(child_path: &Path) -> serde_json::Value {+ let text = fs::read_to_string(child_path).unwrap();+ let (head, rest) = text.split_once('\n').unwrap();+ let mut head: serde_json::Value = serde_json::from_str(head).unwrap();+ head["payload"]+ .as_object_mut()+ .unwrap()+ .remove("subagent_history_start_ordinal");+ fs::write(child_path, format!("{head}\n{rest}")).unwrap();+ head+}++fn rewrite_head(child_path: &Path, head: &serde_json::Value) {+ let text = fs::read_to_string(child_path).unwrap();+ let (_, rest) = text.split_once('\n').unwrap();+ fs::write(child_path, format!("{head}\n{rest}")).unwrap();+}+#[test]fn codex_review_output_is_readable_and_not_duplicated() {setup();diff --git a/crates/wake-core/tests/common/mod.rs b/crates/wake-core/tests/common/mod.rsindex e4a9b7e..55fcad7 100644--- a/crates/wake-core/tests/common/mod.rs+++ b/crates/wake-core/tests/common/mod.rs@@ -14,6 +14,184 @@ pub fn fixture(rel: &str) -> PathBuf {.join(rel)}+/// 一个最小的 Codex home:state DB + 一条用户线程 + 一条 `spawn_agent` 子线程。+/// 子线程的前半段是 `fork_turns` 复制进来的父线程历史,分界点由首行的+/// `subagent_history_start_ordinal` 指定(真机形态,实测 0.151 会写);那一段里+/// 还夹着一封发给**别的**子代理的派活信封,用来卡住"认收件人而不是认第一条+/// 信封"这条兜底判据。fork 段**以助手消息收尾**、子线程自己**从工具调用开头**+/// ——这正是折叠会把子线程自己的工具调用一起 splice 掉的形状。父子关系登记在+/// state DB 的 thread_spawn_edges 里。adapter_contracts 与 scanner_finale 共用+/// 一份,免得两边各写一套慢慢漂开。返回 (父线程 id, 子线程 id, 子线程文件路径)+pub fn stage_codex_spawn_pair(home: &Path) -> (String, String, PathBuf) {+ let parent_id = "11111111-aaaa-4bbb-8ccc-000000000001".to_string();+ let child_id = "22222222-aaaa-4bbb-8ccc-000000000002".to_string();+ let day = home.join("sessions/2026/09/16");+ fs::create_dir_all(&day).unwrap();++ // Codex 给每行编 ordinal(= 行号);子线程首行的+ // subagent_history_start_ordinal 就是按它指的+ let write_jsonl = |path: &Path, lines: &[serde_json::Value]| {+ let text: String = lines+ .iter()+ .enumerate()+ .map(|(ordinal, line)| {+ let mut line = line.clone();+ line["ordinal"] = serde_json::json!(ordinal);+ format!("{line}\n")+ })+ .collect();+ fs::write(path, text).unwrap();+ };+ let session_meta = |id: &str, extra: serde_json::Value| {+ let mut payload = serde_json::json!({+ "id": id,+ "timestamp": "2026-09-16T09:00:00.000Z",+ "cwd": "/work/wake",+ "originator": "codex_cli_rs"+ });+ payload+ .as_object_mut()+ .unwrap()+ .extend(extra.as_object().unwrap().clone());+ serde_json::json!({+ "timestamp": "2026-09-16T09:00:00.000Z",+ "type": "session_meta",+ "payload": payload+ })+ };+ let message = |role: &str, text: &str| {+ serde_json::json!({+ "timestamp": "2026-09-16T09:05:00.000Z",+ "type": "response_item",+ "payload": {+ "type": "message",+ "role": role,+ "content": [{"type": "input_text", "text": text}]+ }+ })+ };+ // 派活信封:抬头明文、Payload 加密,与实测形态一致+ let dispatch = |to: &str| {+ serde_json::json!({+ "timestamp": "2026-09-16T09:30:00.000Z",+ "type": "response_item",+ "payload": {+ "type": "agent_message",+ "author": "/root",+ "recipient": to,+ "content": [+ {"type": "input_text", "text": format!("Message Type: NEW_TASK\nTask name: {to}\nSender: /root\nPayload:\n")},+ {"type": "encrypted_content", "encrypted_content": "gAAAAAB-opaque"}+ ]+ }+ })+ };++ let parent_head = session_meta(+ &parent_id,+ serde_json::json!({"source": "cli", "thread_source": "user"}),+ );+ write_jsonl(+ &day.join(format!("rollout-2026-09-16T09-00-00-{parent_id}.jsonl")),+ &[+ parent_head.clone(),+ message("user", "inherited parent turn about the qr login bug"),+ message("assistant", "inherited parent answer"),+ ],+ );++ let child_head = session_meta(+ &child_id,+ serde_json::json!({+ "source": {"subagent": {"thread_spawn": {+ "parent_thread_id": parent_id,+ "depth": 1,+ "agent_path": "/root/review_issue17",+ "agent_nickname": "Wegener",+ "agent_role": null+ }}},+ "thread_source": "subagent",+ "agent_path": "/root/review_issue17",+ "subagent_history_start_ordinal": 7+ }),+ );+ let child_path = day.join(format!("rollout-2026-09-16T09-30-00-{child_id}.jsonl"));+ write_jsonl(+ &child_path,+ &[+ child_head,+ // spawn 时原样复制进来的父线程首行,saw_session_meta 必须挡住它+ parent_head,+ message("user", "inherited parent turn about the qr login bug"),+ message("assistant", "inherited parent answer"),+ dispatch("/root/other_task"),+ message("user", "inherited follow-up turn"),+ message("assistant", "inherited parent tail"),+ dispatch("/root/review_issue17"),+ serde_json::json!({+ "timestamp": "2026-09-16T09:31:00.000Z",+ "type": "response_item",+ "payload": {+ "type": "function_call",+ "name": "shell",+ "call_id": "call_child_1",+ "arguments": "{\"command\":\"rg useEffect\"}"+ }+ }),+ serde_json::json!({+ "timestamp": "2026-09-16T09:31:01.000Z",+ "type": "response_item",+ "payload": {+ "type": "function_call_output",+ "call_id": "call_child_1",+ "output": "CHILD_TOOL_OUTPUT"+ }+ }),+ message("assistant", "child found the missing dependency array"),+ ],+ );++ // state DB:threads 两行(子线程的 title/name 与真机一样是空的,标题只能+ // 由解析侧的任务名给)+ 父子关系登记表+ let conn = rusqlite::Connection::open(home.join("state_5.sqlite")).unwrap();+ conn.execute_batch(+ "CREATE TABLE threads (id TEXT, rollout_path TEXT, cwd TEXT, title TEXT, name TEXT,+ tokens_used INTEGER, archived INTEGER, git_branch TEXT, model TEXT, source TEXT,+ created_at_ms INTEGER, updated_at_ms INTEGER);+ CREATE TABLE thread_spawn_edges (parent_thread_id TEXT NOT NULL,+ child_thread_id TEXT NOT NULL PRIMARY KEY, status TEXT NOT NULL);",+ )+ .unwrap();+ for (id, file, source) in [+ (+ &parent_id,+ format!("rollout-2026-09-16T09-00-00-{parent_id}.jsonl"),+ "cli",+ ),+ (+ &child_id,+ format!("rollout-2026-09-16T09-30-00-{child_id}.jsonl"),+ // 真机把整个结构化来源原样存进 source 列+ "{\"subagent\":{\"thread_spawn\":{}}}",+ ),+ ] {+ conn.execute(+ "INSERT INTO threads VALUES (?1, ?2, '/work/wake', '', NULL, 0, 0,+ NULL, NULL, ?3, 1789000000000, 1789000000000)",+ rusqlite::params![id, day.join(file).to_string_lossy(), source],+ )+ .unwrap();+ }+ conn.execute(+ "INSERT INTO thread_spawn_edges VALUES (?1, ?2, 'open')",+ rusqlite::params![parent_id, child_id],+ )+ .unwrap();+ drop(conn);++ (parent_id, child_id, child_path)+}+pub fn copy_tree(src: &Path, dst: &Path) {fs::create_dir_all(dst).unwrap();for entry in fs::read_dir(src).unwrap() {diff --git a/crates/wake-core/tests/scanner_finale.rs b/crates/wake-core/tests/scanner_finale.rsindex c6cc818..719c485 100644--- a/crates/wake-core/tests/scanner_finale.rs+++ b/crates/wake-core/tests/scanner_finale.rs@@ -75,6 +75,72 @@ fn temp_store(dir: &Path) -> Arc<Store> {Arc::new(Store::open(&dir.join("scan.db")).expect("open store"))}+/// `spawn_agent` 子代理端到端:进索引、不出现在顶层列表、parent_key 指向+/// 父线程,父行的子会话计数认得它(issue #42)+/// Codex 的登记表是 home 的一张总表,不像 grok 的边车长在 parent 自己的+/// location 里:用户给某个更深的目录单独加了 location 之后,两个文件都归那个+/// 实例,而边只有 home 实例报得出来。"报边者必须拥有 parent"那条按 grok 写的+/// 规矩会把这种边整条丢掉,子会话于是静默变回顶层+#[test]+fn codex_spawn_links_survive_a_deeper_custom_location() {+ let home = tempfile::tempdir().unwrap();+ let (parent_id, child_id, _) = common::stage_codex_spawn_pair(home.path());+ let dir = tempfile::tempdir().unwrap();+ let store = temp_store(dir.path());+ // 默认实例(有 state DB、报得出边)在前,更深的自定义 location 在后——+ // 后者按最长根拥有这两个 rollout+ let adapters: Vec<Box<dyn AgentAdapter>> = vec![+ CodexAdapter::new().with_custom_root(home.path().to_path_buf()),+ CodexAdapter::new().with_custom_root(home.path().join("sessions/2026/09/16")),+ ];+ run_scan(&adapters, &store, &Recorder::new(), true).unwrap();++ assert_eq!(+ store+ .parent_key_of(&format!("codex:{child_id}"))+ .unwrap()+ .as_deref(),+ Some(format!("codex:{parent_id}").as_str())+ );+}++#[test]+fn codex_spawned_subagents_nest_under_their_parent() {+ let home = tempfile::tempdir().unwrap();+ let (parent_id, child_id, _) = common::stage_codex_spawn_pair(home.path());+ let dir = tempfile::tempdir().unwrap();+ let store = temp_store(dir.path());+ let adapters: Vec<Box<dyn AgentAdapter>> =+ vec![CodexAdapter::new().with_custom_root(home.path().to_path_buf())];+ run_scan(&adapters, &store, &Recorder::new(), true).unwrap();++ let parent_key = format!("codex:{parent_id}");+ let child_key = format!("codex:{child_id}");+ let child = store.get_session(&child_key).unwrap().expect("子代理入库");+ assert_eq!(child.title, "review_issue17");+ assert_eq!(+ store.parent_key_of(&child_key).unwrap().as_deref(),+ Some(parent_key.as_str())+ );++ let filter = SessionFilter {+ roots_only: true,+ limit: 10,+ ..Default::default()+ };+ let (roots, total) = store.list_sessions(&filter).unwrap();+ assert_eq!(total, 1, "子代理不进顶层列表");+ assert_eq!(roots[0].key, parent_key);+ assert_eq!(+ store+ .child_counts(&filter)+ .unwrap()+ .get(&parent_key)+ .copied(),+ Some(1)+ );+}+#[test]fn finale_fires_on_empty_scan() {let dir = tempfile::tempdir().unwrap();diff --git a/docs/cli.md b/docs/cli.mdindex 1632e2e..1cc4192 100644--- a/docs/cli.md+++ b/docs/cli.md@@ -61,7 +61,7 @@ wake-cli search -- --dry-run # a query that starts with a dash### `sessions`-The most recently updated sessions. Subagent sessions Wake tracks on their own (Grok) are folded into their parents; Claude Code and Cursor subagent transcripts live inside their session and are read with `show --subagent`; Codex's background threads (auto-review, `/review`, compaction, memory consolidation, spawned sub-agents) are not indexed at all. Archived sessions are excluded. This is what to run when you want the key of "the session from yesterday".+The most recently updated sessions. Sub-agents that their agent records as sessions of their own (Codex `spawn_agent`, Grok) are folded into their parents — `show` on the parent lists them by key; Claude Code and Cursor subagent transcripts live inside their session and are read with `show --subagent`; Codex's background threads (auto-review, `/review`, compaction, memory consolidation) are not indexed at all. Archived sessions are excluded. This is what to run when you want the key of "the session from yesterday".Same options as `search`, plus `--starred` (only sessions you starred in Wake). `--limit` defaults to 20, max 100.diff --git a/docs/mcp.md b/docs/mcp.mdindex e03f3c3..48f02a4 100644--- a/docs/mcp.md+++ b/docs/mcp.md@@ -104,10 +104,10 @@ Everything above happens locally; Wake itself does not change and the other agen### What it does not do- No write tools: nothing can delete, star, rename or resume a session. Resuming stays in Wake.-- Subagent transcripts that live inside a session (Claude Code sidechains, Cursor subagents) are not merged into the main transcript: `wake_get_session` lists their ids at the end and reads one when it is passed as `subagent`. Subagent sessions that Wake tracks as separate sessions (Grok) are folded under their parent in `wake_list_sessions` but can be read by key.+- Subagent transcripts that live inside a session (Claude Code sidechains, Cursor subagents) are not merged into the main transcript: `wake_get_session` lists their ids at the end and reads one when it is passed as `subagent`. Sub-agents that their agent records as sessions of their own (Codex `spawn_agent`, Grok) are folded under their parent in `wake_list_sessions`; the parent's `wake_get_session` output lists them by key, and each reads like any other session.- Antigravity sessions are metadata only — their transcripts are encrypted on disk, so an agent gets the same preview card Wake shows.- Archived Codex sessions appear in search results but not in `wake_list_sessions` or `wake_list_projects`.-- Codex's own background threads — the guardian auto-review, `/review`, compaction, memory consolidation and spawned sub-agents that Codex writes into the same `sessions` directory — are not indexed at all: they never show up in search, lists or project counts, and there is no key to read them by. After upgrading, rows an older Wake had indexed disappear once Wake itself has rescanned (launch it, or press Refresh); `wake-mcp` only reads the index and never rescans.+- Codex's own background threads — the guardian auto-review, `/review`, compaction and memory consolidation that Codex writes into the same `sessions` directory — are not indexed at all: they never show up in search, lists or project counts, and there is no key to read them by. Threads started by `spawn_agent` are the exception: they are work the user asked for, so they are indexed under the session that spawned them, titled with the task name. The turns Codex copies from the parent when it forks a sub-agent are dropped, so the parent's own conversation is only indexed once. After upgrading, rows an older Wake had indexed disappear once Wake itself has rescanned (launch it, or press Refresh); `wake-mcp` only reads the index and never rescans.## Keeping results fresh@@ -194,6 +194,8 @@ inotify queues overflow when …Tool calls are folded to one line each (name plus input preview) unless `include_tools` is set; at most 40 tool calls are listed per message, the rest are counted. Injected context (system reminders, IDE context) is skipped and counted. Compaction summaries are kept as quotes. Images are noted, not included. Subagent transcripts (Claude Code sidechains, Cursor subagents) are listed at the end of the main transcript with their ids; pass one as `subagent` to read it, with the same paging options. The footer lists at most 30; `subagent: "*"` returns the full list without a transcript.+Child sessions (Codex `spawn_agent` sub-agents, Grok sub-sessions) are listed after it, by key — `wake_list_sessions` only returns roots, so the parent is where they are found. A child names its parent in the header line instead.+The footer says which seqs were shown and either `End of transcript.` or a `from_seq=<n>` hint for the next page. Seq numbers are the same ones Wake's own search results and transcript view use.If the key is unknown the tool returns an error result (`isError: true`) explaining what keys look like; if only a bare native id is given, the server looks it up and, when several hosts share that id, lists the candidates.diff --git a/skills/wake/SKILL.md b/skills/wake/SKILL.mdindex ee5a23d..6a40404 100644--- a/skills/wake/SKILL.md+++ b/skills/wake/SKILL.md@@ -63,7 +63,9 @@ wake-cli show 'claude-code:1b2c3d4e-…'Add `--tools` for tool inputs and outputs, `--thinking` for recorded reasoning. Both areverbose — start without them. Work done by subagents (Claude Code sidechains, Cursorsubagents) is not in the main transcript; its ids are listed at the end of the output —-read one with `--subagent ID`, or `--subagent '*'` to list them all.+read one with `--subagent ID`, or `--subagent '*'` to list them all. Sub-agents that run+as sessions of their own (Codex `spawn_agent`, Grok) are listed at the end too, by key;+`sessions` only lists parents, so this is where to find them.**Which projects have history**