feat(play): the saving tab draws no player and closes itself when the package is saved (#104)
Closes #104. Part of missing-elements/h5p-toolkit#210.
In ChatGPT (the owner's runs, 2026-11-24) nothing saves a package over about 8 MB inside the chat's window: its own save refuses the file, it downloads from no web address, and its file store takes no package from a card. So the tab of #102 stays the one-press way. But it read as being sent to a website: it drew the whole player and stayed open.
What a person sees now
In the tab that a press on Download opens (a link with &save=1):
- No player. The stage shows "Getting your video… 96 MB of 230 MB" with its bar and "Choose it from your computer instead", then "Building the activity in your browser…", then "Your .h5p is saved" with the file's name and size.
- The tab closes itself five seconds later, counted down in the text ("This tab closes in 5 s."), and the person is back in the chat.
- "Keep this tab open" stops that. The text then says "If nothing was saved, press Download.", and "Play it here" plays the package in the tab.
- An address that cannot be fetched: the page's own "Add your video", saying "Your video could not be fetched from the chat: its address may have run out. Choose it from your computer; it stays in your browser." The chosen file is built from and saved the same way.
Framed pages, and a link without save, are unchanged.
How
- A new state,
saved, drawn in the stage like the loader and the two questions. - In such a tab the files are fetched first and the package built once, with its files in it; no preview is built and no player mounted.
- The count to closing waits while the page is seen and something else has the keyboard: a question of the browser's own (where to save, whether to allow it) is then likely over the page. A tab the browser does not let a page close stays, with the "press Download" text.
Checked
By hand, as this repository has no page tests: the built site served locally, a store on another origin that answers any site and sends the file over four seconds, the tab opened by another page with window.open(…, 'noopener'), as a chat opens it.
| Case | Result |
|---|---|
| A video at an address (light, 1000 px) | fetching with its count and bar, no player; saved, the package in the downloads; the tab closed itself; the address bar left with #source= only |
| The same, dark at 390 px, "Keep this tab open" | the tab stays past the count; "Play it here" plays the package; Download saves it again |
| A file chosen while the same one is fetched | built from the chosen one, saved, closed |
| The address answers 403 | "Add your video" with the reason; the chosen file built from, saved, closed |
A quiz, no files, save=1 | built, saved, closed |
| A tab not opened by a script | saved; it does not close, and says to press Download where nothing was saved |
| Framed: the cases of #98, #100 and #102, and the six card behaviours of #93 and #95 | unchanged; the tab the framed page asks for now shows the saved view, no player |
- A tab that closes itself right after starting the save of a 230 MB file still had the whole file saved (Chromium, closed 0 ms, 50 ms and 1 s after).
- No page error in any run.
npm run buildpasses. Screenshots of the three views looked at, light and dark, 1000 and 390 px.
Not verified
- Not in ChatGPT.
- Firefox and Safari: whether they save with no press, and whether a save survives the tab closing. Chromium only here.
- A browser set to ask where to save each file: the count is meant to wait for that question; not tried.
Summary by cubic
The saving tab opened from a Download link no longer draws the player or stays open. It fetches the linked files, shows their progress, builds the package once, saves it without a press, and closes the tab after five seconds.
- "Keep this tab open" stops the countdown, and "Play it here" plays the saved package in the tab; the countdown pauses while the page is hidden or unfocused, to wait out browser save dialogs.
- Files that cannot be fetched are asked for by the file picker, and a file chosen while the same one is being fetched replaces it; once an address is fetched or given up on, the package is built from files alone.
- The counted-fetch logic was extracted into a shared helper so the save path reuses it; framed pages and previews are unchanged.