S-page primary-action buttons works randomly with s-app-window

The primary action slot randomly works, for example:

<s-page heading="App Window Title">
  <s-button slot="primary-action" onclick="shopify.toast.show('Save')">Save</s-button>
</s-page>

One time the button shows, the next time it doesn’t.

When it doesn’t work, it also doesn’t show the set heading like “App Window Title” but it will fallback to the app name. It seems like it doesn’t consistently recognizes the elements on the page.