Kalpana-chavhan opened a new issue, #37211:
URL: https://github.com/apache/beam/issues/37211

   ### Description
   
   Currently, the Apache Beam Playground loses all user progress (editor 
content and SDK selection) upon a page refresh. This creates significant 
friction for users who are experimenting with code or accidentally trigger a 
browser reload.
   
   ### Proposed Change
   
   I propose implementing a persistence layer using the browser's 
`localStorage` API to cache the following:
   
   1. Editor Content: The current string in the Monaco editor.
   2. Selected SDK: The active language (Java, Python, Go, SCIO).
   3. User-defined vs Example: Whether the user is viewing a standard example 
or their own custom code.
   
   ### Technical Strategy
   
   1. State Hydration: Load state from `localStorage` during store 
initialization to prevent UI flickering.
   2. Debounced Writes: Implement a 500ms-1000ms debounce for 
`localStorage.setItem` calls to ensure editor performance remains high.
   3. Safety: Wrap JSON parsing in `try/catch` blocks to prevent app crashes if 
local data is corrupted.
   
   ### Impact
   
   - DX Improvement: Users can return to their work even after closing the tab.
   - Zero Backend Impact: This is a localized frontend change that requires no 
API modifications.
   - Testability: The persistence logic can be verified via unit tests 
(Jest/Vitest).
   
   ### I am willing to contribute
   
   I have analyzed the playground/frontend directory and have a draft 
implementation ready using TypeScript.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to