fix: persist and restore user folder config across restarts [IDE-1816]#1196
Draft
nick-y-snyk wants to merge 2 commits intorefactor/IDE-1786_folder-config-refactoringfrom
Draft
Conversation
User folder overrides (additional params, env, org, base branch, etc.)
were lost on restart because:
1. The user:folder: keys were never loaded from storage on startup
2. After JSON round-trip, values deserialized as map[string]interface{}
instead of *configresolver.LocalConfigField, causing silent type
assertion failures in all reader functions
Add coerceToLocalConfigField to handle both in-memory and deserialized
forms. Add RefreshByPrefix to load user:folder: keys from storage on
startup. Handle []interface{} to []string conversion for slice values.
getSettingValue, getStringSliceFromSetting, and getScanCommandConfigFromSetting were not checking the Changed flag on ConfigSetting. This caused unchanged settings sent by the IDE during initialization to overwrite persisted user values (e.g. org_set_by_user being reset to false on restart).
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
ShawkyZ
reviewed
Apr 7, 2026
Comment on lines
+77
to
+101
| func (s *storage) RefreshByPrefix(config configuration.Configuration, prefix string) error { | ||
| s.mutex.Lock() | ||
|
|
||
| contents, err := os.ReadFile(s.storageFile) | ||
| if err != nil { | ||
| s.mutex.Unlock() | ||
| return err | ||
| } | ||
| doc := map[string]interface{}{} | ||
| err = json.Unmarshal(contents, &doc) | ||
| if err != nil { | ||
| s.mutex.Unlock() | ||
| return err | ||
| } | ||
|
|
||
| s.mutex.Unlock() | ||
| for key, value := range doc { | ||
| if strings.HasPrefix(key, prefix) { | ||
| config.PersistInStorage(key) | ||
| config.Set(key, value) | ||
| } | ||
| } | ||
| return nil | ||
| } | ||
|
|
Collaborator
There was a problem hiding this comment.
instead of doing this, use the already registered keys in
When you register a key you can mark it as persistable.
ShawkyZ
reviewed
Apr 7, 2026
Comment on lines
+66
to
+67
| lf, ok := coerceToLocalConfigField(val) | ||
| if !ok { |
Collaborator
There was a problem hiding this comment.
why can't we directly cast?
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.
Description
Fixes folder-level user settings (additional params, env, org, base branch, etc.) not surviving LS restarts after the folder config refactoring.
Root cause: After the refactoring moved folder config values from a monolithic
StoredConfigJSON blob to per-key GAF prefix keys (user:folder:<path>:<name>), the values were correctly written to the JSON storage file on save, but never loaded back on startup. Additionally, after JSON round-trip,*configresolver.LocalConfigFielddeserializes asmap[string]interface{}and[]stringbecomes[]interface{}, causing type assertion failures.Changes:
RefreshByPrefixin storage — loads all keys matching a prefix from the JSON storage file into configuration on startupSetupStoragein config — callsRefreshByPrefixforuser:folder:prefix to restore persisted folder overridescoerceToLocalConfigField— handles both in-memory*LocalConfigFieldand deserializedmap[string]interface{}representationsReadFolderConfigSnapshot— handles[]interface{}→[]stringconversion forAdditionalParametersandLocalBranchesgetSettingValue/getStringSliceFromSetting/getScanCommandConfigFromSetting— requireChanged: trueflag before applying updatesKnown issue:
org_set_by_user/preferred_orgstill gets reset on restart despite being correctly persisted and loaded. Investigation ongoing — the LS should own theChangeddetermination rather than relying on 4 different IDEs to set it correctly.Checklist
make generate)make lint-fix)