feat: optimize context compression and session sync (#402)

* feat: optimize context compression and session sync

Context Compressor:
- Add ContentBlock type support for user messages with images/files
- Enhance buildConversationHistory to handle ContentBlock[] format
- Update serializeForSummary to convert ContentBlock[] to text
- Support mixed content (text, images, files) in history compression

Session Sync:
- Replace loop of addMessage with batch addMessages (transaction-protected)
- Use addMessages for atomic bulk insert with BEGIN/COMMIT
- Ensure data consistency before calcAndUpdateUsage reads DB

Chat Run Socket:
- Remove convertHistoryFormat before compression (compressor handles raw format)
- Compressor now processes original messages for better tool message handling
- Improve compression quality by preserving original message structure

Benefits:
- Better compression quality with proper tool message recognition
- Improved performance with batch DB inserts
- Strong data consistency with transaction protection
- Support for rich content (images/files) in conversation history

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* chore: bump version to 0.5.7

- Prepare for release with context compression and session sync optimizations

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* chore: add 0.5.7 changelog entries

- Optimize context compression to support rich content (images, files)
- Improve session sync with batch inserts and transaction protection
- Fix usage.updated event reception for accurate token tracking

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
ekko
2026-05-02 20:12:58 +08:00
committed by GitHub
parent 8af1951f13
commit 4a9967ebdd
5 changed files with 129 additions and 125 deletions
+3
View File
@@ -767,6 +767,9 @@ export default {
new_0_5_6_6: 'Redesigned attachment handling using Anthropic-style ContentBlock array format with type discriminated unions (text, image, file)',
new_0_5_6_7: 'Added frontend file download functionality supporting both ContentBlock and Markdown formats with authentication',
new_0_5_6_8: 'Fixed multi-process conflict causing SQLite database resets by eliminating redundant nodemon instances',
new_0_5_7_1: 'Optimize context compression to support rich content (images, files) with improved tool message handling',
new_0_5_7_2: 'Improve session sync with batch inserts and transaction protection for data consistency',
new_0_5_7_3: 'Fix usage.updated event reception to ensure accurate token tracking across runs',
new_0_5_5_1: '🎉 Happy Labor Day! No work this Labor Day, please bear with us if there are any issues',
new_0_5_5_2: 'Add History page for browsing Hermes session history',
new_0_5_5_3: 'History page manages session state independently without interfering with active chat',