fix: change Account fields to var for XStream serialization#13
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes critical bug where all Xiaomi and OpenRouter accounts become Cline accounts after IDE restart.
Why
XStream can only deserialize
varfields. TheAccountdata class hadvalfields forid,name,connectionType,authType, andkeyPreview. During deserialization, XStream silently fails to set these fields, causing them to revert to default values:connectionType→CLINE_API(default)authType→CLINE_API_KEY(default)id→ new random UUIDname→ empty stringkeyPreview→ empty stringChanges
Accountdata class fields fromvaltovar:id,name,connectionType,authType,keyPreviewFiles Modified
src/main/kotlin/org/zhavoronkov/tokenpulse/settings/Account.ktsrc/test/kotlin/org/zhavoronkov/tokenpulse/settings/AccountTest.ktVerification