Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Settings v2 #5815

Merged
merged 16 commits into from
Dec 19, 2024
Merged

Settings v2 #5815

merged 16 commits into from
Dec 19, 2024

Conversation

krlvi
Copy link
Member

@krlvi krlvi commented Dec 11, 2024

The broader goal here is to create a good setup for application settings that is ergonomic for users, easy to work with and not error prone. In general, what VSCode does with settings is great and probably a good target - a user can use the UI or edit the JSON, the settings are portable.

Requirements:

  • Settings file is user-editable
  • If the settings file contains mistakes (eg. missing commas etc) it does not break the app
  • The settings file should not contain entries for all defaults values in existence
  • Allow nesting/grouping of related configs
  • The settings should be editable via the UI as well and have those changes reflected in the same file (similar to VSCode)
  • The app should watch/listen for updates in the settings file and upon change reflect that in it's behavior (e.g. need to update the UI)
  • Clear /discoverable defaults
  • Within Rust, settings structs fields should not be Options if there are well defined defaults (development ergonomics)
  • Should be hard to mess something up when adding new config structs or fields to existing structs and their respective update APIs
  • If the settings json file contains comments, the app should not mess with those upon settings changes via the UI

Outstanding questions:

  • Where should the settings file live? ~/.config/gitbutler/settings.json, ~/.gitbutler.json? Somewhere else? How about Windows?
  • Maybe temporarily skip the requirement for preserving comments in the json to simplify implementing?

TODOs:

  • More tests
  • APIs for UI
  • Filesystem watching for the settings file & appropriate actions
  • Settings change event propagation to frontend
  • Preserve comments in the json

Out of scope here:

  • Adopt in typescript
  • Migrate existing settings to the new format
  • Remove LegacySettings and the tauri store plugin

Copy link

vercel bot commented Dec 11, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
gitbutler-components ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 19, 2024 5:53pm
gitbutler-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 19, 2024 5:53pm

Copy link
Collaborator

@Byron Byron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am really excited to see this new settings system come to life!

Given our recent conversation I felt compelled to comment early, despite the draft status and hope you don't mind.

crates/gitbutler-settings/src/persistence.rs Outdated Show resolved Hide resolved
crates/gitbutler-settings/src/persistence.rs Show resolved Hide resolved
crates/gitbutler-settings/vendor/util/src/lib.rs Outdated Show resolved Hide resolved
crates/gitbutler-settings/Cargo.toml Outdated Show resolved Hide resolved
crates/gitbutler-settings/vendor/util/src/lib.rs Outdated Show resolved Hide resolved
@krlvi
Copy link
Member Author

krlvi commented Dec 12, 2024

I am really excited to see this new settings system come to life!

Given our recent conversation I felt compelled to comment early, despite the draft status and hope you don't mind.

Thank you, this was really helpful. I have now implemented your feedback

@Caleb-T-Owens
Copy link
Contributor

All these cool kids using Arc 😆

Copy link
Collaborator

@Byron Byron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went 'all in' on the review and hope I left it more maintainable than before. With that said, please feel free to dial it back here and there. Particularly the names might be overly verbose and could just be simpler.

Please do all the application settings real-world testing once again, I only launched the app once and it seemed to work, but I didn't do any app-setting specific testing.

- add docs according to what I think it does
- make settings access blocking to avoid spurious but avoidable failures.
- rename `SettingsHandle` to `AppSettingsWithDiskSync`, and additional renames to make clear what's happening.
- make interacting with the app-settings more pleasant.
- more robust watcher event loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@gitbutler/desktop rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants