fix: 删除会话后清理 session_index.jsonl 并移除 scheduleScan 残留调用 - #1887
fix: 删除会话后清理 session_index.jsonl 并移除 scheduleScan 残留调用#1887xiaoyang-1999 wants to merge 2 commits into
Conversation
|
感谢修复。当前删除/undo 逻辑还有一个会操作错误路径的问题,暂时不能直接合并:
现有测试把数据库和 移除残留 |
When a Codex thread is deleted, the DB row and rollout file were removed but the matching line in ~/.codex/session_index.jsonl was left behind, so the session kept appearing in the Codex sidebar (and reopening it failed with "no rollout found"). - Keep the removed session_index lines in the backup (__session_index) so undo restores them. - Remove the index entry atomically after the delete commits; failures are reported in the result message but do not fail the delete. - Resolve the Codex home explicitly (default_codex_home_dir) instead of deriving it from the DB path parent, so the new <home>/sqlite/codex-dev.db layout updates <home>/session_index.jsonl as well. - Add regression tests covering delete + undo for both the legacy <home>/state_5.sqlite and the <home>/sqlite/ layouts.
v1.2.47 removed the pluginAutoExpand feature (function definition and the call inside scanDeferred) but left a dangling call in scheduleScan. Every MutationObserver callback then threw "schedulePluginAutoExpand is not a function" before scan() could be scheduled, so session-row action buttons were never attached until something called scan() directly (e.g. opening the Codex++ menu).
2f13775 to
5decfe0
Compare
感谢建议!已按 review 意见改好了:
验证: 麻烦再帮忙看下,谢谢。 |
修复两个从 v1.2.47 开始就存在的问题
问题一:删除会话后列表残留(Windows 环境复现)
Windows 上删完会话,列表里还挂着,点进去提示
no rollout found,再删一次又提示Thread not found in local storage。查下来是删除时只清了 SQLite 里的
threads表和相关 rollout 文件,但~/.codex/session_index.jsonl(新版 Codex 的会话列表索引)里对应的那行没动,列表自然清不干净。这次把删除流程补齐了:
session_index.jsonl里对应的条目移除,写入走原子写,避免把文件写坏问题二:会话行操作按钮不显示
v1.2.47 移除 pluginAutoExpand 功能时,函数定义删了,但
scheduleScan里漏了一处调用没删干净。结果每次 DOM 变化,MutationObserver 回调都先抛TypeError: schedulePluginAutoExpand is not a function,后面的自动重扫根本执行不到。表现就是启动后鼠标悬停会话行不出现删除/导出按钮,必须点一下右上角 Codex++ 菜单(菜单会直接触发一次 scan)按钮才出来。修复就是把
scheduleScan里那行残留调用删掉。验证
cargo test -p codex-plus-data,全部通过(含新增用例)schedulePluginAutoExpand is not a function