Skip to content

fix(history): preserve unchanged messages during sync - #83

Merged
Zhou-Shilin merged 1 commit into
Zhou-Shilin:mainfrom
Chumor:fix/chat-history-incremental-sync
Sep 24, 2026
Merged

Zhou-Shilin merged 1 commit into
Zhou-Shilin:mainfrom
Chumor:fix/chat-history-incremental-sync

Conversation

@Chumor

@Chumor Chumor commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Bug Fixes
    • Chat history now consistently shows only active messages, excluding parked messages from history and related counts.
    • Updating a conversation preserves unchanged messages and their workspace file references while applying changes to the affected portion of the history.
    • Removed messages no longer retain associated agent references, and stale parked messages are cleared during updates.

@coderabbitai

coderabbitai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: ca306caf-4d8a-4121-9bdc-fc3031592f67

📥 Commits

Reviewing files that changed from the base of the PR and between 54583f2 and 8b6f9ea.

📒 Files selected for processing (6)
  • app/src/androidTest/java/com/zhousl/aether/data/ChatRepositoryCheckpointInstrumentedTest.kt
  • app/src/main/java/com/zhousl/aether/data/ChatRepository.kt
  • shared/src/commonMain/kotlin/com/zhousl/aether/data/chatdb/ChatHistoryDao.kt
  • shared/src/commonMain/kotlin/com/zhousl/aether/data/chatdb/ChatHistoryMessageSync.kt
  • shared/src/commonMain/kotlin/com/zhousl/aether/data/chatdb/SharedChatHistoryStore.kt
  • shared/src/commonTest/kotlin/com/zhousl/aether/data/chatdb/ChatHistoryMessageSyncTest.kt

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

Chat history snapshots now use a transactional message-sync operation. It compares canonical active messages with stored rows, updates changed messages and related references, and excludes parked rows from message reads and statistics. Snapshot tests cover parked-row cleanup, preserved message order, and agent-reference cleanup.

Changes

Chat history synchronization

Layer / File(s) Summary
Canonical message sync and DAO persistence
shared/src/commonMain/kotlin/com/zhousl/aether/data/chatdb/ChatHistoryMessageSync.kt, shared/src/commonMain/kotlin/com/zhousl/aether/data/chatdb/ChatHistoryDao.kt, shared/src/commonTest/kotlin/com/zhousl/aether/data/chatdb/ChatHistoryMessageSyncTest.kt
The sync helpers validate message batches, assign dense positions, and find the first changed position. The DAO syncs changed message suffixes and related references, and filters parked rows from reads and statistics. Unit tests cover canonicalization and change detection.
Snapshot callers and checkpoint validation
app/src/main/java/com/zhousl/aether/data/ChatRepository.kt, shared/src/commonMain/kotlin/com/zhousl/aether/data/chatdb/SharedChatHistoryStore.kt, app/src/androidTest/java/com/zhousl/aether/data/ChatRepositoryCheckpointInstrumentedTest.kt
Both snapshot paths call the DAO sync operation with messages and workspace file references. Instrumented tests check parked-row cleanup, overflow and position preservation, and agent-reference cleanup.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant ChatRepository
  participant ChatHistoryDao
  participant chat_messages
  participant chat_workspace_file_refs
  ChatRepository->>ChatHistoryDao: Sync session messages and workspace file refs
  ChatHistoryDao->>chat_messages: Read active rows and compare changed positions
  ChatHistoryDao->>chat_messages: Delete changed suffix and upsert messages
  ChatHistoryDao->>chat_workspace_file_refs: Remove inactive refs and upsert matching refs
Loading

Suggested reviewers: zhou-shilin

Merge Risk: ⚪ Minimal · up to 8b6f9

The identified snapshot and reference risks are not reachable on the inspected paths; the change is mergeable after normal checks.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 5.71% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 35 functions across 6 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: preserving unchanged messages during chat-history synchronization. It is concise and specific.
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

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

Comment @coderabbitai help to get the list of available commands.

@Chumor
Chumor requested a review from Zhou-Shilin September 24, 2026 14:36
@Zhou-Shilin
Zhou-Shilin merged commit 8bff84d into Zhou-Shilin:main Sep 24, 2026
5 checks passed
@Chumor
Chumor deleted the fix/chat-history-incremental-sync branch September 24, 2026 16:08
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