The cluster and node pages swap their live part every few seconds, and the forms inside it went with it: what was typed, an open choice, the focus. Filling one in raced the clock. The swap now waits while a field in the live part has the focus or a form in it has been typed into and not sent; sending it, or leaving the page, ends that. The mirror page's reload during a download goes through the same check instead of http-equiv. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
45666e72db
commit
e78075876b
5 files changed
+57
-10
No files matched your search
@@ -26,6 +26,14 @@ APIs change between minors without a deprecation period.
|
||||
|
||||
## Unreleased
|
||||
|
||||
### Fixed
|
||||
|
||||
- The cluster and node pages swapped their live part every few seconds,
|
||||
forms and all, so filling one in raced the clock: what was typed, an
|
||||
open choice and the focus were lost. The refresh now waits while a field
|
||||
in it has the focus or a form in it has been typed into and not sent;
|
||||
the mirror page's reload during a download waits the same way.
|
||||
|
||||
## v0.14.5 — 2026-10-14
|
||||
|
||||
Picture and 3D models that add themselves where a card fits them, with a
|
||||
|
||||
@@ -239,14 +239,14 @@ func TestThePageReloadsOnlyWhileSomethingIsDownloading(t *testing.T) {
|
||||
|
||||
// A reload while nothing is happening would take with it whatever the
|
||||
// operator was typing into the fetch form.
|
||||
if strings.Contains(idle, "http-equiv=\"refresh\"") {
|
||||
if strings.Contains(idle, "name=\"llmgw-refresh\"") {
|
||||
t.Error("an idle page should not reload itself")
|
||||
}
|
||||
|
||||
busy := mirrorGet(t, mirrorPage(t, &fakeMirror{models: []mirror.Status{
|
||||
{Model: "m", Version: "v", File: "f", State: mirror.Fetching},
|
||||
}}, true), "/admin/mirror").Body.String()
|
||||
if !strings.Contains(busy, "http-equiv=\"refresh\"") {
|
||||
if !strings.Contains(busy, "name=\"llmgw-refresh\"") {
|
||||
t.Error("a page with a download running should follow it")
|
||||
}
|
||||
}
|
||||
@@ -680,7 +680,7 @@ func TestEachTabDoesOnlyItsOwnWork(t *testing.T) {
|
||||
if strings.Contains(held, `name="source" required`) || strings.Contains(held, "Search Hugging Face") {
|
||||
t.Error("other tabs' forms are on the list")
|
||||
}
|
||||
if !strings.Contains(held, `http-equiv="refresh"`) {
|
||||
if !strings.Contains(held, `name="llmgw-refresh"`) {
|
||||
t.Error("the list stopped following a download")
|
||||
}
|
||||
|
||||
@@ -688,7 +688,7 @@ func TestEachTabDoesOnlyItsOwnWork(t *testing.T) {
|
||||
if reg.explored != 1 || !strings.Contains(explore, "Search Hugging Face") {
|
||||
t.Error("the explorer tab did not explore")
|
||||
}
|
||||
if strings.Contains(explore, `id="held"`) || strings.Contains(explore, `http-equiv="refresh"`) {
|
||||
if strings.Contains(explore, `id="held"`) || strings.Contains(explore, `name="llmgw-refresh"`) {
|
||||
t.Error("the explorer shows the list, or reloads away a search")
|
||||
}
|
||||
// A link from before there were tabs still lands on the explorer.
|
||||
|
||||
@@ -92,7 +92,7 @@ func TestAHeldModelOpensToWhereItRunsAndHowMuchRoomIsLeft(t *testing.T) {
|
||||
if strings.Contains(body, "secret-engine-key") {
|
||||
t.Error("the engine's key reached the page")
|
||||
}
|
||||
if strings.Contains(body, `http-equiv="refresh"`) {
|
||||
if strings.Contains(body, `name="llmgw-refresh"`) {
|
||||
t.Error("a page with an open form reloads under the operator")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,50 @@
|
||||
var msg = e.target.getAttribute && e.target.getAttribute('data-confirm');
|
||||
if (msg && !window.confirm(msg)) { e.preventDefault(); }
|
||||
});
|
||||
// A form being filled in is not refreshed away. The live parts of the
|
||||
// cluster and node pages are swapped whole every few seconds, and a form
|
||||
// inside one lost what was typed into it, its open choice, its focus:
|
||||
// filling one in raced the clock. While a field in the refreshing part
|
||||
// has the focus, or a form in it has been typed into and not sent, it
|
||||
// waits; sending the form, or leaving the page, ends that.
|
||||
var edited = [];
|
||||
document.addEventListener('input', function (e) {
|
||||
var f = e.target.form || (e.target.closest && e.target.closest('form'));
|
||||
if (f && edited.indexOf(f) < 0) { edited.push(f); }
|
||||
});
|
||||
document.addEventListener('submit', function (e) {
|
||||
if (!e.defaultPrevented) { edited = []; }
|
||||
});
|
||||
function busy(root) {
|
||||
var a = document.activeElement;
|
||||
if (a && a !== document.body && root.contains(a) &&
|
||||
a.matches('input, select, textarea, [contenteditable]')) {
|
||||
return true;
|
||||
}
|
||||
for (var i = 0; i < edited.length; i++) {
|
||||
if (root.contains(edited[i]) && document.contains(edited[i])) { return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// htmx's trigger filters are evaluated JavaScript; this is the same
|
||||
// "only while visible" without them.
|
||||
// "only while visible" without them, and "not while being filled in".
|
||||
document.addEventListener('htmx:beforeRequest', function (e) {
|
||||
if (document.visibilityState !== 'visible' && e.detail.elt.hasAttribute('data-visible-only')) {
|
||||
var elt = e.detail.elt;
|
||||
if (elt.hasAttribute('data-visible-only') &&
|
||||
(document.visibilityState !== 'visible' || busy(elt))) {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
// A page that reloads itself (<meta name="llmgw-refresh" content="N">)
|
||||
// does it on the same terms, rather than by http-equiv, which nothing
|
||||
// can hold off.
|
||||
var r = document.querySelector('meta[name="llmgw-refresh"]');
|
||||
var every = r ? parseInt(r.getAttribute('content'), 10) : 0;
|
||||
if (every > 0) {
|
||||
setInterval(function () {
|
||||
if (document.visibilityState === 'visible' && !busy(document.body)) {
|
||||
window.location.reload();
|
||||
}
|
||||
}, every * 1000);
|
||||
}
|
||||
})();
|
||||
@@ -1,9 +1,9 @@
|
||||
{{define "admin_mirror"}}<!doctype html>
|
||||
<html lang="{{lang}}"><head>
|
||||
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
{{/* Only while something is downloading. A reload at any other time would
|
||||
take with it whatever the operator was typing into the form below. */}}
|
||||
{{if .RefreshSec}}<meta http-equiv="refresh" content="{{.RefreshSec}}">{{end}}
|
||||
{{/* Only while something is downloading, and not while a form is being
|
||||
filled in: pages.js holds the reload off then. */}}
|
||||
{{if .RefreshSec}}<meta name="llmgw-refresh" content="{{.RefreshSec}}">{{end}}
|
||||
<script defer src="/_static/pages.js"></script>
|
||||
<title>{{t "mirror.title"}} · llmgw</title><link rel="stylesheet" href="{{stylesheet}}">
|
||||
</head><body><div class="wrap">
|
||||
|
||||
Reference in new issue
Block a user