Skip to content

Comments

Add auto-save to localStorage for Playground editor#16782

Merged
Mossaka merged 1 commit intomainfrom
feat/auto-save-localstorage
Feb 19, 2026
Merged

Add auto-save to localStorage for Playground editor#16782
Mossaka merged 1 commit intomainfrom
feat/auto-save-localstorage

Conversation

@Mossaka
Copy link
Collaborator

@Mossaka Mossaka commented Feb 19, 2026

Summary

  • Save editor content to localStorage on every document change so users don't lose work when closing/refreshing the tab
  • On page load, restore saved content from localStorage, falling back to the default Hello World template
  • Clear the sample dropdown when restoring saved content to avoid a misleading selection
  • Wrap localStorage.setItem in try/catch for resilience when storage is full or unavailable

This is a ~10-line change to docs/public/editor/editor.js.

Test plan

  • Load the Playground, edit content, close/refresh the tab -- content should be restored
  • Select a sample template from the dropdown -- it should replace the editor content and auto-save
  • Clear localStorage.removeItem('gh-aw-playground-content') in devtools, reload -- should fall back to Hello World
  • Verify theme preference (gh-aw-playground-theme) is unaffected
  • Verify deep-link hash URLs still override saved content

🤖 Generated with Claude Code

Save editor content to localStorage on every change so users don't
lose their work when closing the tab. On page load, restore saved
content if available, falling back to the Hello World template.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 19, 2026 08:02
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds auto-save functionality to the Playground editor, automatically persisting editor content to localStorage on every document change and restoring it on page load. This prevents users from losing their work when closing or refreshing the browser tab.

Changes:

  • Auto-save editor content to localStorage on every document change
  • Restore saved content from localStorage on initialization, with fallback to default Hello World template
  • Clear sample dropdown when restoring saved content to avoid misleading selection state

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Mossaka Mossaka merged commit 74b23f0 into main Feb 19, 2026
49 checks passed
@Mossaka Mossaka deleted the feat/auto-save-localstorage branch February 19, 2026 08:04
github-actions bot pushed a commit that referenced this pull request Feb 19, 2026
Add definition for the Playground - the interactive web-based editor
powered by the gh-aw WebAssembly compiler, including the auto-save
localStorage feature added in PR #16782.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

1 participant