Skip to content

The playground Save button stays enabled after switching to an example, and the save is lost on reload #1754

Closed

Description

@joshunrau

The playground's Save button stays enabled after switching from a saved instrument with unsaved changes to an example or template, and anything "saved" there is lost on reload. SaveButton recalculates disabled only while the selected instrument's category is Saved. When the user switches away from a dirty saved instrument, the last value, false, is kept. Save is then enabled on an instrument that cannot be saved. Clicking it writes the edits into the in-memory example through updateSelectedInstrument. The store's merge drops every non-Saved instrument on load, so after a reload the example is back to its original code, even though the click gave every sign of success. The button also stays enabled after the click.

Where

apps/playground/src/components/Header/SaveButton/SaveButton.tsx:13-22:

const [disabled, setDisabled] = useState(true);
const editorFiles = useFilesRef();
const selectedInstrument = useAppStore((store) => store.selectedInstrument);
const updateSelectedInstrument = useAppStore((store) => store.updateSelectedInstrument);

useInterval(() => {
  if (selectedInstrument.category === 'Saved') {
    setDisabled(isEqual(editorFiles.current, selectedInstrument.files));
  }
}, 1000);

Reproduce

  1. Click Create New Instrument and save it as Mine, then change index.ts. Save becomes enabled within a second.
  2. Without saving, select Form Reference in the instrument selector.
  3. Change Form Reference's index.ts, click Save, and reload.

Actual: Save is enabled on Form Reference, the click appears to save, and after the reload Form Reference is back to its original code.
Expected: Save is disabled whenever the selected instrument is an example or a template.

Tests

Extract the condition into a helper next to the component and test it in apps/playground/src/components/Header/SaveButton/__tests__/SaveButton.test.ts: it('should disable saving for examples and templates, so a save that cannot persist is never offered').

E2E in testing/src/specs/playground.spec.ts: follow the steps above and assert that the Save button is disabled after switching to Form Reference.

Suggested fix

Recalculate on every tick: setDisabled(selectedInstrument.category !== 'Saved' || isEqual(editorFiles.current, selectedInstrument.files)).

Activity

  1. added
    BugType: existing behavior is wrong
    Priority: LowNice to have, cosmetic or speculative
    Difficulty: LowIsolated change, about 2 hours or less
    Area: Playgroundapps/playground (in-browser instrument editor)
    Good First IssueWell-scoped, low-risk and self-contained; a good entry point for a new contributor
    on Oct 7, 2026
  2. added a commit that references this issue on Oct 29, 2026
    1ac73b8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: Playgroundapps/playground (in-browser instrument editor)BugType: existing behavior is wrongDifficulty: LowIsolated change, about 2 hours or lessGood First IssueWell-scoped, low-risk and self-contained; a good entry point for a new contributorPriority: LowNice to have, cosmetic or speculative

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions