从 JSONL 恢复完整对话。 流程: 1. 逐行解析 JSONL 2. 构建 UUID → entry 映射 3. 找到叶节点(没有被任何 entry 的 parent_uuid 引用的 entry) 4. 从叶节点沿 parent_uuid 回溯 5. 反转得到时间序
(self, session_id: str)
| 96 | return entry.uuid |
| 97 | |
| 98 | def load_session(self, session_id: str) -> list[Message]: |
| 99 | """从 JSONL 恢复完整对话。 |
| 100 | |
| 101 | 流程: |
| 102 | 1. 逐行解析 JSONL |
| 103 | 2. 构建 UUID → entry 映射 |
| 104 | 3. 找到叶节点(没有被任何 entry 的 parent_uuid 引用的 entry) |
| 105 | 4. 从叶节点沿 parent_uuid 回溯 |
| 106 | 5. 反转得到时间序 |
| 107 | """ |
| 108 | path = self._session_path(session_id) |
| 109 | entries = self._read_entries(path) |
| 110 | if not entries: |
| 111 | return [] |
| 112 | |
| 113 | chain = self._rebuild_chain(entries) |
| 114 | return [Message.model_validate(e.message) for e in chain] |
| 115 | |
| 116 | def list_sessions(self) -> list[str]: |
| 117 | """列出所有会话 ID。""" |
nothing calls this directly
no test coverage detected