diff --git a/src/Chronos.Server/Admin/web/admin.css b/src/Chronos.Server/Admin/web/admin.css
index 2d82e168..900fea54 100644
--- a/src/Chronos.Server/Admin/web/admin.css
+++ b/src/Chronos.Server/Admin/web/admin.css
@@ -387,7 +387,9 @@ textarea.input.notes { height: auto; min-height: 64px; padding: 6px 10px; resize
.frame-badge.hero { color: var(--sun); }
.frame-badge.warn { top: auto; bottom: 4px; inset-inline: 4px auto; color: var(--warning); }
.table.renders { grid-template-columns: minmax(100px, 1.4fr) max-content max-content max-content max-content max-content; }
-/* A sequence's projects (owner review 2, R8) and, under one opened, its versions. */
+/* A sequence's projects (owner review 2, R8) and, under one opened, its versions. Their table sits in a wrapper, a grid item
+ of the panel: it may be narrower than the table, so the table's columns fit (fitColumns) instead of the panel scrolling. */
+.panel > .table-host { min-width: 0; }
.table.projects { grid-template-columns: minmax(120px, 1.4fr) max-content minmax(120px, 1.2fr) max-content; }
.table.projects.fit-1 { grid-template-columns: minmax(120px, 1fr) max-content max-content; }
.table.projects.fit-1 .col-changed { display: none; }
diff --git a/src/Chronos.Server/Admin/web/pages/library/projects.js b/src/Chronos.Server/Admin/web/pages/library/projects.js
index 796b3ea2..91a3273f 100644
--- a/src/Chronos.Server/Admin/web/pages/library/projects.js
+++ b/src/Chronos.Server/Admin/web/pages/library/projects.js
@@ -6,6 +6,8 @@ import { escapeHtml, attr, formatNumber, formatDateTime, toast, errorText, confi
/** Versions read at a time when a project is opened, and with each Load more. */
const VERSION_PAGE = 20;
+/** The most versions one read of them gives (ProjectEndpoints.MaxPage): a refresh reads again as many as are shown, up to this. */
+const MAX_PAGE = 200;
/** A project name, as the server takes it (ProjectService.MaxNameLength). */
const MAX_NAME = 60;
/** The name every sequence's Main project is made with; shown in the panel's language. */
@@ -27,6 +29,8 @@ export function projectsSection(host, meta, { api, sequenceId }) {
const expanded = new Set();
let timer = null;
let failed = null;
+ /** The projects a projectChanged named since the last read; null after a reconnection, when any may have changed. */
+ let changed = new Set();
host.innerHTML = `
@@ -40,15 +44,20 @@ export function projectsSection(host, meta, { api, sequenceId }) {
const table = host.querySelector(".table");
const rows = host.querySelector("#project-rows");
- async function load() {
+ /**
+ * Reads the projects again, and the versions of those opened that may have changed (every one when stale is null): as
+ * many as are shown, so the pages Load more read stay.
+ */
+ async function load(stale = null) {
try {
projects = await api.get(base);
failed = null;
- // A project deleted meanwhile (here or elsewhere) closes; the others' versions are read again.
+ // A project deleted meanwhile (here or elsewhere) closes; the versions of the others that changed are read again.
for (const id of expanded) {
if (!projects.some((p) => p.id === id)) forget(id);
}
- await Promise.all([...expanded].map((id) => loadVersions(id).catch(() => forget(id))));
+ const again = [...expanded].filter((id) => stale === null || stale.has(id));
+ await Promise.all(again.map((id) => reloadVersions(id).catch(() => forget(id))));
} catch (err) {
projects = [];
failed = errorText(err);
@@ -58,14 +67,23 @@ export function projectsSection(host, meta, { api, sequenceId }) {
draw();
}
- /** The newest versions of a project, or with more the next page after those shown. */
- async function loadVersions(id, more = false) {
+ /**
+ * The newest versions of a project, or with more the next page after those shown. Read without their settings
+ * (summary): the panel shows none, and a large sequence's versions are megabytes each.
+ */
+ async function loadVersions(id, more = false, limit = VERSION_PAGE) {
const known = versions.get(id);
const before = more && known?.items.length ? `&before=${known.items[known.items.length - 1].number}` : "";
- const page = await api.get(`${base}/${encodeURIComponent(id)}/versions?limit=${VERSION_PAGE}${before}`);
+ const page = await api.get(`${base}/${encodeURIComponent(id)}/versions?limit=${limit}${before}&summary=true`);
versions.set(id, { items: more && known ? known.items.concat(page.items) : page.items, more: page.more });
}
+ /** The newest versions of a project read again, as many as are shown (at least a page, at most MAX_PAGE). */
+ function reloadVersions(id) {
+ const shown = versions.get(id)?.items.length ?? 0;
+ return loadVersions(id, false, Math.min(MAX_PAGE, Math.max(VERSION_PAGE, shown)));
+ }
+
function forget(id) {
expanded.delete(id);
versions.delete(id);
@@ -222,9 +240,13 @@ export function projectsSection(host, meta, { api, sequenceId }) {
return {
onEvent(e) {
if ((e.type === "projectChanged" && e.sequenceId === sequenceId) || e.type === "reconnected") {
+ if (e.type === "reconnected") changed = null;
+ else changed?.add(e.projectId);
clearTimeout(timer);
timer = setTimeout(() => {
- if (host.isConnected) load();
+ const stale = changed;
+ changed = new Set();
+ if (host.isConnected) load(stale);
}, AFTER_CHANGE_MS);
}
},
diff --git a/src/Chronos.Server/Admin/web/pages/library/sequence.js b/src/Chronos.Server/Admin/web/pages/library/sequence.js
index cd3a812f..d3e35a57 100644
--- a/src/Chronos.Server/Admin/web/pages/library/sequence.js
+++ b/src/Chronos.Server/Admin/web/pages/library/sequence.js
@@ -84,7 +84,7 @@ export async function renderSequence(root, { api, setMeta, actions, onEvent }, i
diff --git a/tests/Chronos.Server.Tests/Hosting/AdminProjectsTests.cs b/tests/Chronos.Server.Tests/Hosting/AdminProjectsTests.cs
index 636ad9cf..c26e3dd6 100644
--- a/tests/Chronos.Server.Tests/Hosting/AdminProjectsTests.cs
+++ b/tests/Chronos.Server.Tests/Hosting/AdminProjectsTests.cs
@@ -43,7 +43,16 @@ public sealed partial class AdminProjectsTests(TestContext context)
Assert.True(!Regex.IsMatch(projects, @"\son[a-z]+="""), "inline handler");
// It lists, opens versions, renames and deletes: no push, no restore, no settings (R6: the panel manages, never edits).
Assert.Contains("projects = await api.get(base);", projects);
- Assert.Contains("api.get(`${base}/${encodeURIComponent(id)}/versions?limit=${VERSION_PAGE}${before}`)", projects);
+ // Versions are read without their settings, which the panel never shows (a large sequence's are megabytes each).
+ Assert.Contains("api.get(`${base}/${encodeURIComponent(id)}/versions?limit=${limit}${before}&summary=true`)", projects);
+ // A live refresh reads again only the opened projects an event named (every one after a reconnection), as many
+ // versions as are shown: the pages Load more read stay.
+ Assert.Contains("const again = [...expanded].filter((id) => stale === null || stale.has(id));", projects);
+ Assert.Contains("return loadVersions(id, false, Math.min(MAX_PAGE, Math.max(VERSION_PAGE, shown)));", projects);
+ Assert.Contains("else changed?.add(e.projectId);", projects);
+ // The table's wrapper may be narrower than the table (a grid item of the panel), so its columns fit on a phone.
+ Assert.Contains(@"", page);
+ Assert.Contains(".panel > .table-host { min-width: 0; }", await server.Client.GetStringAsync("/admin/admin.css"));
Assert.Contains("await api.patch(`${base}/${encodeURIComponent(project.id)}`, { name });", projects);
Assert.Contains("await api.del(`${base}/${encodeURIComponent(project.id)}`);", projects);
Assert.False(projects.Contains("api.post(", StringComparison.Ordinal), "the panel pushes or makes nothing");
@@ -110,6 +119,17 @@ public sealed partial class AdminProjectsTests(TestContext context)
Assert.Equal((1, "imported"), (first.GetProperty("number").GetInt32(), first.GetProperty("kind").GetString()));
Assert.True(first.TryGetProperty("storedAt", out _) && first.TryGetProperty("createdAt", out _) && first.TryGetProperty("clientName", out _));
Assert.False(json.RootElement.GetProperty("more").GetBoolean());
+ Assert.NotEqual(string.Empty, first.GetProperty("settingsJson").GetString());
+ }
+ // The page's own form: the same versions, without their settings.
+ using (var versions = await browser.SendAsync(HttpMethod.Get, $"{url}/{vertical}/versions?limit=20&summary=true"))
+ {
+ await versions.ExpectAsync(HttpStatusCode.OK);
+ using var json = JsonDocument.Parse(await versions.Content.ReadAsStringAsync());
+ var first = json.RootElement.GetProperty("items").EnumerateArray().Single();
+ Assert.Equal((1, "imported", string.Empty), (first.GetProperty("number").GetInt32(), first.GetProperty("kind").GetString(),
+ first.GetProperty("settingsJson").GetString()));
+ Assert.Equal(64, first.GetProperty("contentHash").GetString()!.Length);
}
using (var renamed = await browser.SendAsync(HttpMethod.Patch, $"{url}/{vertical}", Json("""{"name":"Vertical"}""")))