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

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

Open
Stu-Duguid opened this issue Apr 14, 2024 · 5 comments
Open

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

Stu-Duguid opened this issue Apr 14, 2024 · 5 comments

Comments

@Stu-Duguid
Copy link

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:

  • save the file, later open it and paste it in.
  • generate a new permalink and replace the one in my bookmarks

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
Copy link
Owner

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
Copy link
Author

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

@caksoylar
Copy link
Owner

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
Copy link
Owner

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
Copy link
Owner

I am tracking streamlit/streamlit#861 to utilize in order to add support for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants