Skip to content

fix: change Account fields to var for XStream serialization#13

Merged
DimazzzZ merged 1 commit into
mainfrom
fix/account-serialization-var-fields
Jun 22, 2026
Merged

fix: change Account fields to var for XStream serialization#13
DimazzzZ merged 1 commit into
mainfrom
fix/account-serialization-var-fields

Conversation

@DimazzzZ

Copy link
Copy Markdown
Owner

What

Fixes critical bug where all Xiaomi and OpenRouter accounts become Cline accounts after IDE restart.

Why

XStream can only deserialize var fields. The Account data class had val fields for id, name, connectionType, authType, and keyPreview. During deserialization, XStream silently fails to set these fields, causing them to revert to default values:

  • connectionTypeCLINE_API (default)
  • authTypeCLINE_API_KEY (default)
  • id → new random UUID
  • name → empty string
  • keyPreview → empty string

Changes

  • Changed all Account data class fields from val to var:
    • id, name, connectionType, authType, keyPreview
  • Added tests to verify fields are mutable and preserved after copy

Files Modified

  • src/main/kotlin/org/zhavoronkov/tokenpulse/settings/Account.kt
  • src/test/kotlin/org/zhavoronkov/tokenpulse/settings/AccountTest.kt

Verification

  • All tests pass ✓
  • Detekt clean ✓

XStream can only deserialize var fields. val fields (private final in
Java bytecode) cannot be set during deserialization, causing all accounts
to revert to default values (CLINE_API) on restart.

Changed all Account data class fields from val to var:
- id, name, connectionType, authType, keyPreview

Added tests to verify fields are mutable and preserved after copy.
@DimazzzZ DimazzzZ merged commit 307b972 into main Jun 22, 2026
2 checks passed
@DimazzzZ DimazzzZ deleted the fix/account-serialization-var-fields branch June 22, 2026 15:53
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.

1 participant