-
Notifications
You must be signed in to change notification settings - Fork 22
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
Auto-sync Cockpit settings with BlueOS #701
Auto-sync Cockpit settings with BlueOS #701
Conversation
94745d2
to
79a095c
Compare
79a095c
to
b742866
Compare
b742866
to
886e307
Compare
Hello Rafael :) I was hoping to include this PR in my testing branch, to give it some time in the water, but there are a few merge conflicts against current master, for example: #857 I'm a little bit torn, as I tried to fix it up, but then I end up with some parts of the code that is now using the old useStorage() method, and I am not familiar enough with the codebase to tell if this is going to be okay'ish or if it could cause trouble. Any chance you could rebase this on current master when you have some spare time? I know it is not a small ask, so no rush, just wanted to let you know that this currently making it a bit difficult for me to test :) Much love, thank you for all your hard work <3 |
Hey Chris! Everything cool? Sure! Let me take a look at that. |
886e307
to
9d76664
Compare
@goasChris just rebased it. Can you take a look? |
Yep, no problems pulling in the PR now :) Well, besides failing CI/autotests, but I'm not too concerned about that, hehe. Thank you very much! |
9d76664
to
76493d9
Compare
Nice! No problem! Also, just fixed the CI, it was an unused import left in the code. Let us know if you have anything more, and feel free to open issues around problems and/or feature requests, so we can track and discuss them! Edit: strangely, there's a test for widget-loading failing, even if this part of the code wasn't touched here. Will investigate more. |
I've tried to debug why the tests are failing, but not being very familiar with ts, bun or vitest for that matter, I essentially just ended up setting a higher timeout, and printing a bunch of stuff. Unsure if its useful, or if its just noise.
|
The strange part is that none of those things were modified... BTW have you been able to use the PR? |
I unfortunately have not been able to test it, cus the only way I know how to fairly easily get the extension input one of our bots is to rely on CI (which won't build heh) |
2bd32a0
to
77ae20a
Compare
a309deb
to
374ba77
Compare
351e730
to
781cc84
Compare
781cc84
to
b9c64ce
Compare
b9c64ce
to
7c613da
Compare
@ArturoManzoli @patrickelectric Fixed. |
@rafaellehmkuhl You are the best! Thank you for all the good work. I have to admit I am extremely curious how you fixed CI, since I failed to do so myself. |
I actually did nothing 😂 I wrote the comment before the CI finished running and afterwards realized it was fixed by itself. Probably a bug on some dynamically versioned package. |
src/composables/settingsSyncer.ts
Outdated
{ text: 'Use the value from BlueOS', action: () => preferBlueOs() }, | ||
{ text: "Keep Cockpit's value", action: () => preferCockpit() }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ text: 'Use the value from BlueOS', action: () => preferBlueOs() }, | |
{ text: "Keep Cockpit's value", action: () => preferCockpit() }, | |
{ text: 'Use the value from BlueOS', action: preferBlueOs }, | |
{ text: "Keep Cockpit's value", action: preferCockpit }, |
This should work, right ?
The `useBlueOsStorage` composable will keep a setting in sync between local storage and BlueOS. The initial value will be the one stored on BlueOS. If we fail to get the value from BlueOS on the first seconds after boot, we will ask the user if they prefer to use the value stored locally or the value stored on BlueOS. Once everything is in sync, if the local value changes, it will update the value on BlueOS. In resume, the initial source of truth is BlueOS, and once everything is in sync, the source of truth is the local value.
This can be used to check if the path was not set, and should then be set for the first time.
This is now done automatically by the settings syncer.
This prevents bloat of the user's storage as well as problematic behaviors when the user changes devices.
Prevents updates on one part of the code that brakes the other that is not connected to it.
We were using it to check if the widget was ever mounted, so it already satisfies the requirements. Updating it on every mount was causing the profile to change all the time, which makes syncing dificult.
7c613da
to
1aedae6
Compare
This is a major patch, that changes how Cockpit works with its settings fundamentally.
With it, instead of having the browser
localStorage
as the source of truth for its settings, Cockpit now uses the backend (provided here by the bag-of-holdings service on BlueOS) to sync Cockpit's storage with BlueOS.There's a pipeline, where Cockpit first tries to fetch its settings from BlueOS. We call it the initial sync. If the values differ, the user will be asked which one they want to keep.
After a successful sync, it then starts to use its own variables, now synced, as the new source of truth. We do that so the settings are always stored in the vehicle, but in the case the user changes something in Cockpit, this change is pushed to the BlueOS storage as the new (updated) value.
In case something goes wrong during the initial fetch (e.g.: the vehicle was not connected yet), Cockpit will keep trying to sync. When the vehicle connects, if the user has made no change to the settings, nothing will happen, but if the user has made some change during this interval, a popup will open asking if the user prefers to keep the changes made in Cockpit or prefers to use the value stored on BlueOS. We do that so we don't overwrite changes explicitly made by the user.
I'm opening this as a draft because I'm still testing to see if everything works correctly, but the code structure is ready and there won't be major changes.Fix #666.
To be merged after #559.