Skip to content

Autosave doenetml source in dev environments - #1423

Open
siefkenj wants to merge 4 commits into
Doenet:mainfrom
siefkenj:autosave-dev
Open

Autosave doenetml source in dev environments#1423
siefkenj wants to merge 4 commits into
Doenet:mainfrom
siefkenj:autosave-dev

Conversation

@siefkenj

@siefkenj siefkenj commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.0 for 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.

Comment thread packages/standalone/src/test-main.tsx Outdated
Comment thread packages/standalone/src/test-main.tsx
<graph />
<mathInput />`;

let saveTimer: number | null = null;
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.

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),
);
}
Comment thread packages/doenetml-iframe/src/test-main.tsx
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.

Comment thread packages/standalone/src/test-main.tsx Outdated
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(
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@siefkenj

siefkenj commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

@dqnykamp Should be ready for merge

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

Successfully merging this pull request may close these issues.

2 participants