diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-08-15 15:48:36 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-08-15 15:48:36 +0200 |
| commit | 4066c754a613deb965472853fe69727d68be593e (patch) | |
| tree | f93b7d7129576f7406a2c97ac7399a8d7e606897 /packages/meshbay-hub/src/meshbay_hub/static/transfers.js | |
| parent | 8528bce49bb637f4e9fb653fff148b7ea45cfdac (diff) | |
| download | meshbay-4066c754a613deb965472853fe69727d68be593e.tar.gz | |
fix(downloads): automatic really is automatic, and a selection downloads all of it
Two bugs in what shipped last, and both were mine.
Automatic mode still opened Save As, because with no folder granted the
code fell through to the file picker — while the documentation said it
would use the browser's own download folder. It does that now. Over
512 MB it still asks, since getting there means holding the file in
memory and a tab will not survive a 40 GB blob; Settings is where to stop
it asking again.
Selecting two files downloaded one. They were started without awaiting,
so each asked the browser for a save dialog at once, and a browser allows
exactly one — the rest were rejected and the errors went nowhere. They
are awaited one at a time now, which serializes the dialogs and not the
transfers: each call returns as soon as its transfer is registered.
Then the adjustments. The transfers widget offers Open on a finished
download that went into a granted folder — the bytes go to a new tab, and
that is the whole of what a page can do: no browser lets one start a
desktop application or show a file manager, so the folder half of that
request cannot be built and the guide says so.
The Files toolbar was four controls of three different heights in a row.
It is three groups now — what you can add, where you are, what you can do
with what is here — on one baseline, with icons from the set and a gap
between the dots and the word Actions. Chat comes first among the tabs
and is the one you land on. The three Discover entries in the sidebar
have icons. And a link in a chat message becomes a link: built as an
element and never as markup, http and https only, so `javascript:` is not
one message away from running here.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-hub/src/meshbay_hub/static/transfers.js')
| -rw-r--r-- | packages/meshbay-hub/src/meshbay_hub/static/transfers.js | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/transfers.js b/packages/meshbay-hub/src/meshbay_hub/static/transfers.js index 1ad1ec5..fa34c67 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/transfers.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/transfers.js @@ -56,6 +56,9 @@ export class TransferStore { error: it.error || '', speed: this._speed(it), percent: it.total ? Math.min(100, Math.round(it.done / it.total * 100)) : 0, + // Only for a file written into a folder the browser granted us: that is + // the one case where the page can read its own download back. + canOpen: it.status === 'done' && typeof it.open === 'function', })); } @@ -79,10 +82,10 @@ export class TransferStore { * `run` receives `{ signal, onProgress }`. It must poll `signal.aborted` — a * cancel that only sets a flag nobody reads is a button that lies. */ - start({ kind, name, total = 0, transport = null, run }) { + start({ kind, name, total = 0, transport = null, run, open = null }) { const item = { id: _nextId++, - kind, name, total, transport, + kind, name, total, transport, open, done: 0, status: 'running', error: '', @@ -128,6 +131,19 @@ export class TransferStore { return item.id; } + /** + * Hand a finished download to the browser to display. + * + * As close to "open it" as a web page gets: the bytes go to a new tab and the + * browser decides what to do with them. A page cannot start a desktop + * application, and cannot show a file manager — there is no API for either, + * in any browser, by design. + */ + open(id) { + const item = this._items.find(it => it.id === id); + if (item && typeof item.open === 'function') return item.open(); + } + cancel(id) { const item = this._items.find(it => it.id === id); if (!item || item.status !== 'running') return; |