From 65282ef4a4bbde2fc9b84241ad51b56c992ecd2b Mon Sep 17 00:00:00 2001 From: Aleksandr Shevchuk Date: Wed, 25 Nov 2026 10:49:51 +0200 Subject: [PATCH 1/2] fix: Download in a chat's frame that saves nothing opens a tab that saves the package, or says the way by hand (#114) A chat's frame may drop the page's own download with nothing said, and nothing tells a page that it does: in Grok a press on Download did nothing. So a framed page does not count on its own download where the parent does not save for it. Where the parent opens links and a tab can build the package, Download hands the parent a link to a tab that builds and saves it; elsewhere the browser is left to try, and the way that works in any frame is said under the stage. --- src/h5p/play/play-page.ts | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/h5p/play/play-page.ts b/src/h5p/play/play-page.ts index 61ef404..73c9a7e 100644 --- a/src/h5p/play/play-page.ts +++ b/src/h5p/play/play-page.ts @@ -33,6 +33,13 @@ import { baseName, compactSource, fragmentFromSource, fragmentWithLinks, kindOf, * again (#100). A link of this page opens nothing there on a press, so a parent that opens links * says so too, and is handed the address. * + * A parent may save no file for the page, in a frame that drops the page's own download all the + * same: in Grok a press on Download did nothing, with nothing said (2026-11-25, #114), and nothing + * tells a page that its frame drops a download. So a framed page does not count on its own: where + * the parent opens links and a tab can build the package, from its source and the addresses of its + * files, Download hands the parent a link to a tab that saves it, as below; elsewhere the browser + * is left to try, and the way by hand is said under the stage at the press. + * * One press is asked for all the same (#102), and a package built in a frame cannot be passed to * a tab: the browser keeps a framed page's storage apart. But a tab can build it again from what * the frame had, the source and the files' addresses, where the store behind the addresses answers @@ -378,6 +385,16 @@ const savingLink = (): string => `${location.origin}${location.pathname}${fragme */ const BY_HAND = 'To save it, right-click Download, or press and hold it, and open the link in a new tab.' +/** The way by hand, said after something else: with no "To save it" of its own. */ +const BY_HAND_TOO = 'Right-click Download, or press and hold it, and open the link in a new tab.' + +/** + * Whether a tab of this page could build the package that plays: every file the source names is + * at an address the parent gave, or it names none. A file the person chose here is in this frame + * only. + */ +const tabBuilds = (): boolean => !linksFor(wanted).missing.length + /** A package bigger than the parent saves: the browser is left to save it, and the way is said where it may not. */ function tooBig(size: number): void { saying(`This .h5p is ${sized(size)}, more than the chat saves with one press. ${BY_HAND}`) @@ -737,7 +754,20 @@ download.addEventListener('click', (event) => { } return fetchToKeep() } - if (hostSaves === null || !kept) return + if (!kept) return + if (hostSaves === null) { + // A tab of the page's own: the browser saves what its link names. + if (!framed) return + // Framed, with no parent that saves: the frame may drop the download with nothing said (#114). + // A tab the parent opens builds the package again and saves it, where a tab can build it. + if (hostOpens && tabBuilds()) { + event.preventDefault() + toParent({ type: 'open', href: savingLink() }) + return saying(`A new tab builds your .h5p and saves it. No tab? ${BY_HAND_TOO}`) + } + // Else the browser is left to try, and the way that works in any frame is said. + return saying(`Nothing saved? ${BY_HAND_TOO}`) + } if (kept.size > hostSaves) return tooBig(kept.size) event.preventDefault() if (!handed) handOver(kept) From 256f767bc5c37b03b0505db510eea79c109c4b93 Mon Sep 17 00:00:00 2001 From: Aleksandr Shevchuk Date: Wed, 25 Nov 2026 10:54:07 +0200 Subject: [PATCH 2/2] fix: a tab saves the package only where its source names no file, since a file it was built with is in the frame (#114) --- src/h5p/play/play-page.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/h5p/play/play-page.ts b/src/h5p/play/play-page.ts index 73c9a7e..880f48d 100644 --- a/src/h5p/play/play-page.ts +++ b/src/h5p/play/play-page.ts @@ -36,9 +36,9 @@ import { baseName, compactSource, fragmentFromSource, fragmentWithLinks, kindOf, * A parent may save no file for the page, in a frame that drops the page's own download all the * same: in Grok a press on Download did nothing, with nothing said (2026-11-25, #114), and nothing * tells a page that its frame drops a download. So a framed page does not count on its own: where - * the parent opens links and a tab can build the package, from its source and the addresses of its - * files, Download hands the parent a link to a tab that saves it, as below; elsewhere the browser - * is left to try, and the way by hand is said under the stage at the press. + * the parent opens links and the source names no file, so that a tab builds the same package from + * the source alone, Download hands the parent a link to a tab that saves it, as below; elsewhere + * the browser is left to try, and the way by hand is said under the stage at the press. * * One press is asked for all the same (#102), and a package built in a frame cannot be passed to * a tab: the browser keeps a framed page's storage apart. But a tab can build it again from what @@ -389,11 +389,12 @@ const BY_HAND = 'To save it, right-click Download, or press and hold it, and ope const BY_HAND_TOO = 'Right-click Download, or press and hold it, and open the link in a new tab.' /** - * Whether a tab of this page could build the package that plays: every file the source names is - * at an address the parent gave, or it names none. A file the person chose here is in this frame - * only. + * Whether a tab of this page would build the package kept here: only where its source names no + * file. A file it was built with is in this frame, chosen here or brought here, whatever address + * a preview played it from before: a tab would fetch that address again, for a file that may be + * another by now. */ -const tabBuilds = (): boolean => !linksFor(wanted).missing.length +const tabBuilds = (): boolean => !wanted.length /** A package bigger than the parent saves: the browser is left to save it, and the way is said where it may not. */ function tooBig(size: number): void { @@ -759,7 +760,7 @@ download.addEventListener('click', (event) => { // A tab of the page's own: the browser saves what its link names. if (!framed) return // Framed, with no parent that saves: the frame may drop the download with nothing said (#114). - // A tab the parent opens builds the package again and saves it, where a tab can build it. + // A tab the parent opens builds the package again and saves it, where a tab builds the same one. if (hostOpens && tabBuilds()) { event.preventDefault() toParent({ type: 'open', href: savingLink() })