- Modified ChatRecordingService.initialize to accept an explicit overwriteHistory flag.
- When overwriteHistory is true (e.g., after chat compression), it overwrites disk messages; otherwise, it preserves existing historical metadata (IDs/timestamps).
- Updated GeminiChat and GeminiClient.startChat to propagate this flag, ensuring it is only true during the compression flow.
- Refactored apiContentToMessageRecords for full type safety by removing unsafe type assertions and adding part fallbacks, as suggested in PR review.
- Updated unit tests in chatRecordingService.test.ts and client.test.ts to verify the new behavior and fix regression.
- Verified all workspace and integration tests pass via preflight.
Fixes#21335
- Modified ChatRecordingService.initialize to accept an optional initialHistory parameter.
- When initialHistory is provided during session resumption (e.g., after chat compression), it now overwrites the messages in the session file on disk.
- Updated GeminiChat constructor to pass the history to ChatRecordingService.initialize.
- Implemented apiContentToMessageRecords helper to convert API Content objects to storage-compatible MessageRecord objects.
- This ensures that the compressed chat history (the summary) is immediately synced to disk, preventing it from being lost when the session is closed and resumed.
- Added a unit test in chatRecordingService.test.ts to verify the new overwrite behavior.
Fixes#21335