Autosave doenetml source in dev environments - #1423
Open
siefkenj wants to merge 4 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a dev-only persistence layer for edited DoenetML so developers no longer need to keep modifying testCode.doenet to get a “sticky” local iteration loop (per #1270).
Changes:
- Persist dev-editor DoenetML source to
localStorage(standalone + iframe test harnesses) with debounced writes. - Expose Vite dev servers on
0.0.0.0for easier access in remote/dev-container environments. - Reformat embedded demo DoenetML in the standalone
index.html.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/standalone/vite.config.ts | Sets Vite dev server host to 0.0.0.0. |
| packages/standalone/src/test-main.tsx | Loads initial editor source from localStorage and autosaves edits with debounce. |
| packages/standalone/index.html | Adjusts whitespace/indentation of embedded DoenetML demo content. |
| packages/doenetml-iframe/vite.config.ts | Sets Vite dev server host to 0.0.0.0. |
| packages/doenetml-iframe/src/test-main.tsx | Initializes editor source from localStorage and autosaves via immediateDoenetmlChangeCallback. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| <graph /> | ||
| <mathInput />`; | ||
|
|
||
| let saveTimer: number | null = null; |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Comment on lines
+11
to
+34
| const SAVE_DEBOUNCE_MS = 500; | ||
|
|
||
| const saveTimers = new Map<string, ReturnType<typeof setTimeout>>(); | ||
|
|
||
| // Wired to the editor's immediate (per-keystroke) change callback, so debounce | ||
| // the writes: calling localStorage.setItem synchronously on every keystroke can | ||
| // noticeably block the UI for larger documents. | ||
| function saveSource(key: string, source: string) { | ||
| const pending = saveTimers.get(key); | ||
| if (pending !== undefined) { | ||
| window.clearTimeout(pending); | ||
| } | ||
| saveTimers.set( | ||
| key, | ||
| window.setTimeout(() => { | ||
| saveTimers.delete(key); | ||
| try { | ||
| localStorage.setItem(key, source); | ||
| } catch { | ||
| // Ignore localStorage failures in constrained environments. | ||
| } | ||
| }, SAVE_DEBOUNCE_MS), | ||
| ); | ||
| } |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Comment on lines
+18
to
+23
| function saveSource(key: string, source: string) { | ||
| const pending = saveTimers.get(key); | ||
| if (pending !== undefined) { | ||
| window.clearTimeout(pending); | ||
| } | ||
| saveTimers.set( |
This was referenced Jul 8, 2026
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Contributor
Author
|
@dqnykamp Should be ready for merge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Address the issue in #1270 by saving edited doenetml code to localstorage so that testCode.doenet does not need to be edited for a persistent dev experience.