Skip to content

fix(mapping-store): keep a Thread's recency when only its checkpoints change - #946

Merged
BytePioneer-AI merged 1 commit into
BytePioneer-AI:mainfrom
sduhantao-maker:fix/thread-recency-on-checkpoint-refresh
Nov 21, 2026
Merged

BytePioneer-AI merged 1 commit into
BytePioneer-AI:mainfrom
sduhantao-maker:fix/thread-recency-on-checkpoint-refresh

Conversation

@sduhantao-maker

@sduhantao-maker sduhantao-maker commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Opening an old DeepSeek Harness Thread moved it to the top of the Desktop and Web sidebars, though nothing new was said in it.

Opening an external Thread aligns its Turn mappings with the Harness Snapshot. DSH writes its version into every checkpoint locator, so after a DSH upgrade the first open of an old Thread rewrote all of its mappings. That write moved updatedAt, which clients use as the Thread's recency.

Reconciliation now keeps updatedAt when the same Turns stay in the same order and only what the Harness records about them changed. Added, removed or reordered Turns still count as activity.

Related issues

N/A

Test plan

Rebased on main (ce6c90a), Node 24.13.1, macOS 27.2.1 (arm64):

  • npx vitest run --config tests/vitest.config.js packages/mapping-store: 155 passed, including the checkpoint-only case in index.test.ts.
  • npm run typecheck, npm run lint, npx prettier --check .: passed. Full vitest: no failures beyond those main has on this machine (a missing cargo, locally installed apps).
  • Diagnosis: between two backups of an affected record, only nativeCheckpointRef.locator.dshVersion differed, yet updatedAt had moved. Replaying reconciliation on a copy of that store with this change kept updatedAt.
  • By hand: a Thread untouched for weeks, with checkpoints from dsh 0.2.1-rc.5, opened under dsh 0.2.2-rc.5. Its checkpoints were refreshed and its updatedAt did not change.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug 修复
    • 调整 Turn 映射变更的更新时间记录:增删或重排 Turn 时会更新 Thread 的时间戳;仅更改同一组 Turn 的映射内容时则保留原时间戳。
    • 同一组 Turn 的映射内容变更仍会增加版本号。

Turn 映射协调现在根据 Turn 身份和顺序决定是否更新 updatedAt。测试覆盖删除、重排以及仅替换 checkpoint 的情况,并验证 revision 变化。

Changes: Turn 映射更新时间

Layer / File(s) Summary
映射协调与更新时间判断
packages/mapping-store/src/mapping-store.ts, packages/mapping-store/test/index.test.ts
新增 sameTurns,按顺序比较映射数量、hostTurnId 和 nativeTurnRef。#update 支持根据当前记录和更新记录判断是否保留 updatedAt。Turn 删除或重排时更新时间会更新;仅替换相同 Turns 的 checkpoint 时更新时间保持不变,revision 增加。测试使用可控时钟验证这些情况。

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: bytepioneer-ai

Merge Risk: Minimal · up to 8be58

Opening an old Thread after a Harness upgrade should no longer move it to the top of the sidebar, because checkpoint-only changes keep the Thread's recency. Added, removed or reordered Turns still count as activity. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed 标题“fix(mapping-store): keep a Thread's recency when only its checkpoints change”与变更内容直接相关。变更在 mapping-store 中新增 sameTurns,并在 Turn 身份与顺序不变时保留 updatedAt,正对应“仅 checkpoint 变化时保留 Thread 的时效性”。标题覆盖了主要变更。
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed PR 描述与变更集直接相关。描述说明了问题原因:DSH 升级后,打开旧 Thread 时 checkpoint locator 中的 dshVersion 变化导致映射被改写,进而更新 updatedAt,使旧 Thread 在侧边栏顶部出现。描述还说明了修复方式:当 Turn 的身份和顺序不变时保留 updatedAt;增加、删除或重排 Turn 仍视为活动。测试计划列出了具体的测试命令、结果和…
Full details: Description check

Explanation

PR 描述与变更集直接相关。描述说明了问题原因:DSH 升级后,打开旧 Thread 时 checkpoint locator 中的 dshVersion 变化导致映射被改写,进而更新 updatedAt,使旧 Thread 在侧边栏顶部出现。描述还说明了修复方式:当 Turn 的身份和顺序不变时保留 updatedAt;增加、删除或重排 Turn 仍视为活动。测试计划列出了具体的测试命令、结果和手工验证步骤。

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
Fix failing CI checks

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 81a584a and 8be5850.

Files selected for processing: 2

  • packages/mapping-store/src/mapping-store.ts
  • packages/mapping-store/test/index.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

Recent review details

Context from checks skipped due to timeout: 8

  • GitHub Check: CodeRabbit
  • GitHub Check: Web Host tests
  • GitHub Check: Check macos-26
  • GitHub Check: Static checks
  • GitHub Check: Vitest
  • GitHub Check: Check windows-latest
  • GitHub Check: Check ubuntu-22.04
  • GitHub Check: Check Linux ARM64

… change

Opening an external Thread aligns its Turn mappings with the Harness
Snapshot. The DeepSeek Harness writes its version into every checkpoint,
so after a DSH upgrade each old Thread rewrote all of its mappings on the
first open. That write moved updatedAt, which clients use as the Thread's
recency, and the Thread jumped to the top of the Desktop and Web sidebars
although nothing new was said in it.

Reconciliation now keeps updatedAt when the same Turns stay in the same
order and only what the Harness records about them changed. Added, removed
or reordered Turns still count as activity.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sduhantao-maker
sduhantao-maker force-pushed the fix/thread-recency-on-checkpoint-refresh branch from 8be5850 to b2eeda1 Compare November 19, 2026 13:31
@BytePioneer-AI
BytePioneer-AI merged commit 357ec30 into BytePioneer-AI:main Nov 21, 2026
8 checks passed
@BytePioneer-AI

Copy link
Copy Markdown
Owner

Merged, thanks @sduhantao-maker! Verified against #973 (merged just before): Turn start/end advance recency through the default update path, while your reconciliation keeps the original time when only checkpoints change, and both PRs' tests pass together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants