fix(play): a package too big for the chat's save is still built in the chat, and links open on a press (#100)

Merged
AL
10h ago
+40-48

Closes #100. Part of missing-elements/h5p-toolkit#210.

In ChatGPT (the owner's run, 2026-11-24) a 230 MB Interactive Video could not be downloaded without leaving the chat: #98 refused a package bigger than the card saves and pointed to the build page, where the video has to be chosen again. And a press on "Open in the build page" opened nothing in the card. Both worked only from the browser's own menu on the link (right-click, "Open link in new tab").

What a person sees now

  • A package bigger than the chat saves: Download fetches the video and builds the package in the chat, as before #98. Then the row under the stage says: "This .h5p is 235 MB, more than the chat saves with one press. To save it, right-click Download, or press and hold it, and open the link in a new tab."
  • The chat answers that it did not save: "The chat did not save it. To save it, right-click Download, or press and hold it, and open the link in a new tab."
  • "Open in the build page": opens on a press where the framing page opens links.
  • The row's own "Open in the build page" button is gone. The one in the bar stays.
  • A package the chat does save, and the page outside a chat: as before.

For the page that frames this one

MessageWayWhat it does
{ type: 'opens' }to the pageThe framing page opens links itself. Optional.
{ type: 'open', href }from the pageA link of the page was pressed: open this address. Sent only after opens, and only for a plain press; a press with a key held and the browser's own menu are left to the browser.
sizes beside linksto the pageNo longer read. Only the refusal used it.

saves, save and saved are as in #98, but above max the page no longer refuses: it leaves the save to the browser and says the way above.

Checked

By hand, as this repository has no page tests: the built site served locally and framed by a page of another origin acting as a card, with a store on a third origin. "Sandboxed" is a frame with sandbox="allow-scripts allow-same-origin allow-forms", which lets the page save nothing and open no tab, as ChatGPT's card was found to.

CaseResult
A quiz, max 64 MB, the card answers yes (light and dark at 720 px, light at 360 px; once sandboxed)"The chat is saving…", then "Saved…", then the row goes; the browser saves nothing
A quiz, the card first answers with another number, with no number, with no okthe row stays on saving until the real answer
A quiz, the card answers no (sandboxed; light at 720 px, dark at 360 px)the did-not-save row with the way to save it; Download stays a link to the package
A quiz above maxthe too-big row; no save; the browser saves water.h5p
The same, sandboxedthe too-big row; nothing saved, as in a chat; Download is a link to the package
An Interactive Video from its address, above maxneeds-bytes, the package built with the video in it (6.3 MB), the too-big row; the browser saves it
The same, sandboxed (720 and 360 px)the same row; nothing saved; Download is a link to the package
An Interactive Video, max 64 MBsaved by the card, as in #98
No savesthe browser saves, no row: as before
opens, a press on "Open in the build page" (sandboxed)one open with /h5p/build/#source=…; no tab
No opens, the same pressa tab opens, as before; sandboxed, nothing opens, as in a chat today
  • The six card behaviours of #93 and #95: unchanged.
  • No page error in any run. npm run build passes. Screenshots of the rows looked at.

Not verified

  • Not in ChatGPT. That the browser's menu on Download saves a built package there is the owner's report of the run before #98, not a test of this branch.
  • "Press and hold" on a phone, in a chat's own app: not tried.
  • The card's side: answering open with the chat's own way to open a link is the next step of h5p-toolkit#210.
  • Chromium only.

Summary by cubic

Fixes the play page so a package too big for the chat to save is still built in the chat instead of sending the person back to the build page to re-choose a video, and so the page's links open on a press where the framing chat opens them itself.

  • Oversized packages stay ready behind Download as a plain link, with right-click or press-and-hold instructions where the frame saves nothing.
  • The row's "Open in the build page" button is removed; the one in the bar stays.
  • A framing page can send { type: 'opens' } to have pressed link addresses handed back as { type: 'open', href }; the browser keeps key-modified presses and its own menu.
  • The sizes field beside links is no longer read.