caksoylar / keymap-drawer

Visualize keymaps that use advanced features like hold-taps and combos, with automatic parsing
https://caksoylar.github.io/keymap-drawer
MIT License
736 stars 62 forks source link

Feature request: use browser local storage to remember the yaml #91

Open Stu-Duguid opened 7 months ago

Stu-Duguid commented 7 months ago

I frequently tweak my layout and keep track of it with this great tool on the web. To save a change and later revisit it, I either have to:

Could the option be added to auto-save the current yaml into the browser storage? This would not lose the state on browser updates

caksoylar commented 7 months ago

That makes sense, thanks for the suggestion. I had a look and it looks like it might be possible with third party components for Streamlit. They all look hacky to various degrees but I will play with them a bit and see if it is feasible.

Stu-Duguid commented 7 months ago

what about using a cookie rather than localstore? this third party piece looks a possibility https://github.com/ktosiek/streamlit-cookies-manager

caksoylar commented 7 months ago

That's probably more feasible -- local storage access seems to be async so it is a headache to get it to play well with streamlit widgets. Cookie size limit (4 kb?) shouldn't be much of an issue in practice either, if we use the same encoding scheme as the share URL.

That component looks OK, although some forks seem better maintained. I also don't get why they need cookies to be encrypted in public apps, if it is indeed stored in the user's browser?

https://github.com/NathanChen198/streamlit-cookies-controller seems a bit better to me on an initial glance.

caksoylar commented 7 months ago

I tried a few things over the week, unfortunately I haven't found a solution that works robustly. Neither above component nor https://github.com/Mohamed-512/Extra-Streamlit-Components (which seems very poorly maintained in terms of up to date dependencies, I added some fixes in my own fork) seems to be able to set cookies consistently, nor read them on initial start. At least the method in https://gist.github.com/skannan-maf/f803cddee9cc555ceb62405124d418a3 (that uses unsupported features) can fetch cookies consistently.

I'll probably circle back to this in the future, it is a common ask by Streamlit users so a working solution should eventually pop up -- hopefully as an officially supported feature.

caksoylar commented 4 months ago

I am tracking https://github.com/streamlit/streamlit/issues/861 to utilize in order to add support for this.