Repository navigation
Conversation
added 18 commits
November 11, 2026 19:39
Import fidelity - read `rollout-*.jsonl.zst` with the runtime's own node:zlib zstd decoder (no new dependency, no conversion of Codex data); multi-frame rollouts are decoded frame by frame instead of stopping at frame one - stream rollouts instead of `readFileSync`, so the 256 MiB guard no longer hides real conversations (default cap now 2 GiB); two sessions here (388 MiB and 1.2 GB) were previously invisible - drop the Codex desktop envelopes that leaked into transcripts as user messages: `<skill>` (whole SKILL.md), `<codex_internal_context>`, `<guardian_tool_descriptions>`, `<external_codex_apps_*>`, `<in-app-browser-context>`, `<heartbeat>`, `<no retained transcript delta entries>`; `<proposed_plan>` and `<send_user_message_question_reply>` stay - carry goal mode across: read `event_msg/thread_goal_updated` and replay it as the `goal/change` events DSH derives goals from (create + transition); on re-import append only a changed phase Catalog fidelity - new `lib/codex-index.mjs`: titles and projects come from `~/.codex/state_5.sqlite` (`threads.name`, `projects.name`, `project_roots.path`), with `session_index.jsonl` and the rollout as fallbacks - group the picker by Codex project (one project owns several repo roots) and hide guardian reviews / spawned sub-agents by default, matching the sidebar - workspace titles are the Codex project name, never a path; auto-generated `base (path)` titles are migrated at startup and on attach - export writes `thread_goal_updated` so a DSH goal reappears in Codex Compatibility - resolve `@deepseek-ai/dsh-session-format-*` inside the Desktop app on Windows (`process.resourcesPath` → `app.asar/dsh/node_modules`), which the v0→v4 migration needs on that platform - accept host 0.2.2-rc.1; listen to `agent/created` (the old `agent/session-start` name does not exist, so autoImport never ran) - importing no longer reloads the page; the result panel offers a manual refresh instead - test harness: Windows-safe ESM imports (`pathToFileURL`), zstd/native decoding in tests, new suites for the Codex index and workspace titles Verification: 12 suites / 77 tests green; `node --check` clean on lib+bin; `npm pack --dry-run` still ships cordis.patch.yml and lib/client.js.
DSH's JSONL backend keeps one write handle per Session id and refuses a second (`session "…" is already owned by an active write handle`), which is exactly the state of a chat that is open in the GUI while it is being re-imported. - survive the busy case: one retry after 300 ms (the handle is released when the view switches away), then skip that session with a [busy] hint instead of failing the whole batch; every other append error still fails loud - report `busy N` in the result line plus an actionable hint - lib/persistence-facade.mjs exports isSessionBusyError (by name or message) - tests: a busy session is skipped while its siblings still update; other append errors still reject
The importer hardcoded `agentPreset: 'cordis'` in the Session header, and `cordis` is the built-in 创造模式 (plugin-authoring) preset, so every chat synced from Codex opened in it. DSH fixes a session's preset at creation (`agentPresetProjectionDefinition.init` reads the header; later changes need an `agent-preset/selected` event and are only allowed while the session is blank). - default imported sessions to `standard` (标准模式) (`DEFAULT_IMPORT_AGENT_PRESET` in lib/import-service.js) - keep it selectable: `config.importAgentPreset`, or `/import-codex --preset ptc` - lib/dsh-writer.mjs writes the same default - tests: default is `standard`; an explicit preset wins
`@deepseek-ai/dsh-goal` validates a goal log strictly: `create` must be revision 1, phase active, zero rounds; every later change is exactly revision+1 and keeps `createdAt` and `roundsStarted`; `pause`/`block` only apply to an active goal; `resume` is the only path back to active; and a goal id may be created ONCE per session (`seenGoalIds`). The importer broke the last rule in two ways, so the goal projection on re-imported chats failed with "goal create requires a fresh active revision-one goal with zero rounds" and goal mode never took effect: - `diffImportEvents` slices the rebuilt log up to its end, so the trailing goal `create` came back with every re-imported turn → duplicate create. Goal events are now filtered out of the diffed suffix (they are appended only by the goal helper). - a Codex goal that moved back to active was written as a second `create` instead of `resume`. Re-imports now read the stored goal (phase, revision, createdAt, updatedAt) back from the log and continue it with the transitions the fold admits; an impossible move out of `complete` appends nothing. Tests exercise the real fold: create → pause → blocked → resume must stay admissible (operations and revisions asserted), and a re-imported turn must not duplicate the create. Verified on the real rollout that failed before: one `create#1:active`, `foldGoal` accepts it.
DSH 没有删除 Session 的接口(workspace 控制器只有 archive/unarchive/pin/unpin), 所以「归档」之后会话文件仍在,重新导入仍会被判定为已存在。新增面板把这件事做对: - client: ImportPicker 增加 manage 模式(同步设置 → 管理已同步),复用导入视图的 项目分组/搜索/三态勾选框,底部按钮换成红色「删除 N」,删前二次确认;行内不再重复 标注「已导入」,只保留「有更新」。 - host: GET /dsh-codex-sync/catalog?only=imported 只返回已导入线程 (listImportCatalog 新增 onlyImported),POST /dsh-codex-sync/delete 走 lib/delete-imported.mjs。 - lib/delete-imported.mjs: 删除会话目录 + projection 缓存,并在删除前通过 workspaceRegistry.unarchiveSession 清掉归档标记(否则同 id 重导会被隐藏; SQLite 索引按「索引有、磁盘无」自行收敛)。只允许 codex- 前缀;正在 DSH 中打开的 会话拒绝删除;不在存储里的 id 记为 missing;dryRun 只报告不动手;Codex 原始对话 永不触碰。 - tests: 6 个新用例(删除产物+缓存+归档标记、拒绝原生会话、拒绝正在打开的会话、 missing、dryRun、路径定位),全套 88 项。
Codex 会把一个线程分页写成多个 rollout 文件:基础 `rollout-<ts>-<uuid>.jsonl[.zst]` 加上后续 `rollout-<ts>-<uuid>_<fork>` 分段,它们带着同一个 `session_meta.payload.id`,只包含增量轮次。导入器早已按 id 合并,但 `listImportCatalog` 是「一个文件一行」,于是这些线程在导入/管理面板里按分段数重复 出现(本机 6 个线程、多出 8 行)。 - lib/import-service.js: 目录按会话 id 折叠——同一 id 只产出一行,`createdAt` 取最早、 `lastTime` 取最新(保证「有更新」判定正确),并补齐 cwd/parentRawId。 - test: 新增「分段线程只出现一行」用例,断言 lastTime 覆盖最新分段。 - 实机验证:目录从 87 行降到 79 行,重复 id 为 0。
`workspace.attachSession()` 在注册表把 id 过滤掉时(归档会话永远进不了 `workspace.sessionIds`)会**正常返回、不报错**,导入器把它当成成功,于是会话既不在任何 工作区、侧边栏也就没有位置显示——表现就是「导入成功但对应项目下找不到」。 - lib/attach-workspaces.mjs: attach 后用 `workspace.sessionIds.includes(id)` 校验; 失败先重试一次(写入后 header 索引可能滞后 300ms);仍未挂上则输出 `[ungrouped] <id> → <工作区>: <原因>`,并追加提示「关闭该对话后运行 /attach-workspaces」。 - test: 新增「注册表静默不收(归档)时报告 ungrouped」用例;fake registry 补 sessionIds,便于断言。 - 现场核对(本机):`codex-01a1c47b…` 会话文件确实写入 `...\ZBWX\2.0\zbwx-frontend-v2`,live host 的 persistence.list() 也能看到它,但 `workspace.json` 里没有任何工作区收录它 → 正是上面的静默失败。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
一、读取与导入:现在能读到 Codex 的全部会话
.jsonl.zst压缩会话node:zlibzstd 解码,零新依赖、不转换 Codex 数据readFileSync撞 Node 字符串上限,256 MiB 以上直接跳过@deepseek-ai/dsh-session-format-*,导入必失败process.resourcesPath → app.asar/dsh/node_modules解析0.2.2-rc.1真实收益:本机两个会话(388 MB / 1.2 GB,6090 / 8882 条消息)此前根本不在列表里,现在可正常导入。
二、标题、项目与工作区命名
~/.codex/state_5.sqlite):threads.name才是侧边栏显示的名字(threads.title常常是粘贴的原文),项目取projects.name+project_roots.path。此前用session_index.jsonl(缺约 25% 线程、可能过期)并按目录名猜项目,导致一个 Codex 项目被拆成多条。{"subagent":{"other":"guardian"}},本机约 985 条)与 spawn 子代理按threads.source识别后隐藏,与 Codex 侧边栏一致;需要时用--include-subagents。zbwx-frontend-v2 (~/…/zbwx-frontend-v2)→zbwx-v2。旧自动标题会在启动和每次挂载时迁移,你手动改过的标题不动。agent/created(这个 DSH 版本没有agent/session-start,导致 autoImport 与标题迁移一直是空转)。三、机器包裹层过滤:聊天记录只剩真实内容
Codex 会把自己的工具上下文塞成用户消息。以下全部过滤(含带属性的变体):
<skill>/<skills>(整份 SKILL.md)、<codex_internal_context>、<guardian_tool_descriptions>、<external_codex_apps_*>、<in-app-browser-context>、<external_browser_tabs>、<node_repl_review_evidence>、<heartbeat>、<environment_context>、<turn_aborted>、<citation_entries>、<no retained transcript delta entries>,以及<oai-mem-citation>(记忆引用块)。<oai-mem-citation>是特例:它追加在正文末尾,前导标签判定看不见,所以额外做了「从文本中间剪除 + 剪完为空则整块丢弃」。刻意保留:
<proposed_plan>(真实正文)与<send_user_message_question_reply>(用户自己的回答)。数据:本机 1134 个 rollout 里,泄漏的包裹层从约 8100 块降到 0;含记忆引用的 125 个 rollout 解析后残留 0。
四、会话模式:不再是「创造模式」
导入时把
agentPreset: 'cordis'硬编码进会话头,而cordis正是 DSH 内置的创造模式(插件创作预设),于是每个同步来的对话都以创造模式打开。standard(标准模式)importAgentPreset,或/import-codex --preset ptc(standard/ptc/minimal/cordis)现场核对:5 个
codex-*会话全部是cordis,13 个原生会话全部是standard—— 问题在导入逻辑,不在环境默认值。五、目标模式(Goal):真正生效
@deepseek-ai/dsh-goal的规约很严格:create必须 revision 1 / active / 0 rounds;之后每次变更恰好 revision+1 且保留createdAt、roundsStarted;pause/block只能从 active;回到 active 只能靠resume;同一 goal id 在一个会话里只能创建一次。thread_goal_updated(最后一次快照生效)并重放为 DSH 的goal/change;未完成的目标导入后仍是 active,暂停的仍是 paused。导出时反向写回 Codex 快照(active/paused直映;blocked→paused;complete不作为活动目标导出)。create又带上一遍、以及目标变回 active 时写成第二个create而不是resume。现在 goal 事件不走 diff 路径,重导从会话日志读回已存目标并续接。验证:测试直接调用真实
foldGoal折叠产出事件(create → pause → blocked → resume全链通过);此前报错的 rollout 重导后phase=active, revision=1。六、待同步列表:重复行与侧边聊天
…-<uuid>.jsonl加…-<uuid>_<fork>分段,共用同一session_meta.id),而目录是「一个文件一行」。现在按会话 id 折叠,lastTime取最新分段(否则「有更新」判定会漏)。本机 6 个线程、多出 8 行 → 0 重复标题。forked_from_id,同名同历史前缀),列表里于是出现两条同名对话。现在识别forked_from_id并在导入与列表中都跳过;分页分段的history_base指向自己,不会被误判。本机 27 个 fork 线程全部命中过滤。七、管理已同步:真正的删除(新增)
DSH 没有删除 Session 的接口(只有 archive / unarchive / pin / unpin),归档后文件仍在、重导仍判为已存在。
新增面板 Sync → 管理已同步:按项目分组、搜索、三态勾选,底部红色「删除 N」,二次确认。
codex-*(你在 DSH 里自建的对话永远删不到)[deleted]/[refused],全是拒绝时标题显示「没有删除任何会话」(此前 200 响应被当成成功,看起来像按钮没反应)八、问答卡片:双向映射
Codex 把用户回答存成 markup:
<send_user_message_question_reply>[{questionItemId, question, answer}],DSH 里没有任何代码认识它,只能当源码打印。user/message(source.kind = 'user-question-reply'、surfaceOp = 'append'、正文为{questions, answers}JSON),渲染成「已回答」卡片;callId从questionItemId解出,跳过的问题selected: []。真实会话实测 48 张卡片。questionItemId重建为["request_user_input_async","call_…",<index>],往返 callId / 问题 id / 问题 / 答案逐字段一致。source.kind是封闭白名单(不含user-question-reply),直接写会报cannot safely transform unclassified message source并中断整批。现在迁移期降级为user、迁移后按消息 id 恢复(当前 v4 写入校验接受该 kind)。九、结果反馈:部分成功不再伪装成成功
[skipped-migration] <id>: <原因>+migration-failed N,其余照常导入[busy] …+busy NattachSession被过滤时不报错),表现为「导入成功但侧边栏找不到」sessionIds、重试一次,仍失败输出[ungrouped] …并提示运行/attach-workspacesmigration-failed > 0→busy > 0→十、验证
sessionFormatCatalog.encodeCurrentEvent+restoreReleasedV4Artifact十一、升级
装完完整退出并重启 DSH Desktop(只刷新页面不够)。
十二、已知限制
blocked目标导出为paused;complete的目标不作为活动目标导出tokensUsed/timeUsedSeconds不换算成 DSH 的roundsStarted(含义不同)English summary
Reading & import — zstd rollouts are decoded with the runtime's own
node:zlib, multi-frame files frame by frame; reading is streamed with a 2 GiB ceiling (two local sessions of 388 MB / 1.2 GB were invisible before); the session-format migration packages resolve inside the Desktopapp.asaron Windows; host0.2.2-rc.1is accepted; a successful import no longer reloads the page.Titles, projects, workspaces — titles and projects come from
~/.codex/state_5.sqlite(threads.name,projects.name,project_roots.path); guardian reviews and spawned sub-agents are hidden like the Codex sidebar; workspaces are named after the Codex project, never a path; startup hooks listen toagent/created(the old event name never fired).Envelope filtering —
<skill>,<codex_internal_context>,<guardian_tool_descriptions>,<external_codex_apps_*>,<in-app-browser-context>,<heartbeat>,<oai-mem-citation>(appended to real text, cut out mid-block) and friends are dropped;<proposed_plan>and<send_user_message_question_reply>are kept on purpose.Session preset — imports hardcoded
agentPreset: 'cordis'(创造模式); they now default tostandard, overridable viaconfig.importAgentPresetor/import-codex --preset.Goal mode — Codex goal snapshots are replayed as
goal/changeand exported back asthread_goal_updated; the strict fold only allows onecreateper goal id, so re-imports now continue the stored goal (resume/pause/block/complete) instead of re-creating it. Verified with the realfoldGoal.Catalog — paginated continuation segments fold into one row; Codex side chats (
forked_from_id) are neither imported nor listed.Manage synced (new) — DSH has no delete-Session API, so archive kept the artifact and blocked a clean re-import. The new panel lists every chat this plugin wrote (including side chats and orphaned imports), grouped by project, with checkbox deletion that only accepts
codex-*ids, refuses a chat that is open, clears the archive flag, and removes the artifact plus its projection cache.Question answers — imported as DSH's answered-question card and exported back as the Codex envelope (
questionItemIdrebuilt identically, round trip verified); the v2→v3 migration's closedsource.kindwhitelist is worked around by downgrading during the chain and restoring afterwards.Feedback — a session the migration cannot transform is skipped and reported (
[skipped-migration],migration-failed N) instead of aborting the batch; a chat left untouched because it is open is reported as[busy]; unattached workspaces are reported as[ungrouped]; the result page turns into a warning state (「部分会话未导入」 / 「部分会话未更新」) whenever a batch is only partially done.Verification — 13 suites / 100 tests green; 1275 real rollouts, 11 projects / 82 chats, no duplicate titles.
Upgrade — install from GitHub, fully quit and restart DSH Desktop; chats imported by an older build must be deleted and re-imported to pick up presets, goals, answer cards and the new filters.