Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review (claude): bound the publish-date fan-out and label the age chip

[._.]/ Adam Eivy30eeda44b1de
diff --git a/client/src/components/settings/LocalLlmTab.jsx b/client/src/components/settings/LocalLlmTab.jsx
index 34c08e142f..a6622c7a4b 100644
--- a/client/src/components/settings/LocalLlmTab.jsx
+++ b/client/src/components/settings/LocalLlmTab.jsx
@@ -1830,7 +1830,7 @@ export function LocalLlmTab() {
<span
title={`Published ${formatDateNumeric(createdMs)}${Number.isFinite(updatedMs) ? ` · updated ${timeAgo(m.updatedAt)}` : ''}`}
>
- {formatAgeDays(m.createdAt)}
+ published {formatAgeDays(m.createdAt)}
</span>
)}
{isHf && m.license && <span>{m.license}</span>}
diff --git a/client/src/components/settings/MtplxCheckpoints.jsx b/client/src/components/settings/MtplxCheckpoints.jsx
index 036e46516a..b742b57ebc 100644
--- a/client/src/components/settings/MtplxCheckpoints.jsx
+++ b/client/src/components/settings/MtplxCheckpoints.jsx
@@ -225,7 +225,7 @@ export default function MtplxCheckpoints({
{Number.isFinite(row.downloads) ? ` · ${row.downloads.toLocaleString()} downloads` : ''}
{/* Age in days, not a "3mo ago" bucket: a checkpoint's release
date is what says whether it is worth a multi-gigabyte pull. */}
- {age && <span title={`Published ${formatDateNumeric(row.publishedAt)}`}>{` · ${age}`}</span>}
+ {age && <span title={`Published ${formatDateNumeric(row.publishedAt)}`}>{` · published ${age}`}</span>}
{row.license ? ` · ${row.license}` : ''}
</p>
</div>
diff --git a/client/src/components/settings/MtplxServerCard.test.jsx b/client/src/components/settings/MtplxServerCard.test.jsx
index 3a233a6720..929c708eb3 100644
--- a/client/src/components/settings/MtplxServerCard.test.jsx
+++ b/client/src/components/settings/MtplxServerCard.test.jsx
@@ -90,6 +90,27 @@ describe('MtplxServerCard', () => {
expect(handlers.onRemoveModel).toHaveBeenCalledWith('Example/Cached-MTP');
});
+ it("shows a search hit's age in days, and no age for a repo the Hub had no date for", async () => {
+ // The age is what says whether a checkpoint is worth a multi-gigabyte pull, and
+ // a dateless row must stay silent rather than rendering a placeholder age.
+ const publishedAt = new Date(Date.now() - 5 * 24 * 3600 * 1000).toISOString();
+ await renderCard(
+ { installed: true, running: false, supported: true, cachedModels: [] },
+ {
+ onSearchModels: vi.fn().mockResolvedValue({
+ models: [
+ { repo: 'Example/Dated-MTP', name: 'Dated MTP', owner: 'Example', downloads: 12, publishedAt },
+ { repo: 'Example/Undated-MTP', name: 'Undated MTP', owner: 'Example', downloads: 3, publishedAt: null },
+ ],
+ error: null,
+ }),
+ },
+ );
+
+ expect(await screen.findByText(/published 5 days ago/)).toBeInTheDocument();
+ expect(screen.getByText(/Example\/Undated-MTP/)).not.toHaveTextContent(/published/);
+ });
+
it('marks an already-cached search hit instead of offering to download it again', async () => {
await renderCard(
{
diff --git a/client/src/utils/README.md b/client/src/utils/README.md
index 7371a43770..63bb8cc256 100644
--- a/client/src/utils/README.md
+++ b/client/src/utils/README.md
@@ -22,7 +22,7 @@ grep -i "what you want to do" client/src/utils/README.md
| Module | Purpose |
|---|---|
-| `formatters` | Date/time/duration/byte/word formatters (`clamp`, `formatBytes`, `formatDownloadGb` (decimal-GB model download size, "~29 GB"), `formatCompactCount`, `timeAgo`, `formatAgeDays` (age in whole DAYS — "412 days old" — where `timeAgo` would collapse to "1y ago"; model-download lists), `formatTimecode`, `formatDurationMs`, `formatDateShort`, `formatContextTokens` (suffix-less context length, "4K"), `throughputLabel` (a measured model's speed as one label — tok/s where the runtime reported token counts, `~` prefixed when frame-counted, else chars/s; never both), `parseTimeoutMs`, `formatCooldown`, `recommendedRamGb`, `nameFromImageFilename`, `formatUsd` — one USD renderer (`signed` puts the minus outside the `$`; `trimWhole` drops `.00` on a typed round price) — `formatWeight` / `formatPercent` — round unit-converted floats (`170.35000000000002` → `170.4 lbs`) so raw binary precision never reaches a tile — `middleTruncate` — clip a long string from the MIDDLE so its distinguishing tail survives, where CSS `line-clamp`/`text-overflow` always eats the end — …) plus timeout-input bounds and `getAppName`. Do not re-define formatters inside components. **Never write `new Date(x).toLocaleDateString()` inline** — pick the helper for the shape you want: `formatDateNumeric` ("3/5/2026", compact cells), `formatDateShort` ("Mar 5, 2026"), `formatDate` ("March 5, 2026"), `formatDateFull` ("Saturday, March 5, 2026"), `formatWeekdayDate` ("Monday, Mar 5", `{ weekday, year }`), `formatMonthDay` ("Mar 5"), `formatMonthYear` ("March 2026"), `formatWeekdayShort` ("Mon"), `formatWeekdayTime` ("Mon, 7:00 AM"), `formatTimeOfDay` ("1:30 PM"), `formatTimeOfDaySeconds` ("1:30:45 PM", log/queue rows), `formatClockTime` ("02:30:45 PM"; `{ seconds, hour12, timeZone }`), `formatDateTime`. All of them anchor a bare `YYYY-MM-DD` at LOCAL midnight (a naive `new Date('2026-03-05')` is UTC midnight and renders as the previous day west of Greenwich) and take a fallback instead of rendering the literal "Invalid Date". |
+| `formatters` | Date/time/duration/byte/word formatters (`clamp`, `formatBytes`, `formatDownloadGb` (decimal-GB model download size, "~29 GB"), `formatCompactCount`, `timeAgo`, `formatAgeDays` (age in whole DAYS — "412 days ago" — where `timeAgo` would collapse to "1y ago"; model-download lists), `formatTimecode`, `formatDurationMs`, `formatDateShort`, `formatContextTokens` (suffix-less context length, "4K"), `throughputLabel` (a measured model's speed as one label — tok/s where the runtime reported token counts, `~` prefixed when frame-counted, else chars/s; never both), `parseTimeoutMs`, `formatCooldown`, `recommendedRamGb`, `nameFromImageFilename`, `formatUsd` — one USD renderer (`signed` puts the minus outside the `$`; `trimWhole` drops `.00` on a typed round price) — `formatWeight` / `formatPercent` — round unit-converted floats (`170.35000000000002` → `170.4 lbs`) so raw binary precision never reaches a tile — `middleTruncate` — clip a long string from the MIDDLE so its distinguishing tail survives, where CSS `line-clamp`/`text-overflow` always eats the end — …) plus timeout-input bounds and `getAppName`. Do not re-define formatters inside components. **Never write `new Date(x).toLocaleDateString()` inline** — pick the helper for the shape you want: `formatDateNumeric` ("3/5/2026", compact cells), `formatDateShort` ("Mar 5, 2026"), `formatDate` ("March 5, 2026"), `formatDateFull` ("Saturday, March 5, 2026"), `formatWeekdayDate` ("Monday, Mar 5", `{ weekday, year }`), `formatMonthDay` ("Mar 5"), `formatMonthYear` ("March 2026"), `formatWeekdayShort` ("Mon"), `formatWeekdayTime` ("Mon, 7:00 AM"), `formatTimeOfDay` ("1:30 PM"), `formatTimeOfDaySeconds` ("1:30:45 PM", log/queue rows), `formatClockTime` ("02:30:45 PM"; `{ seconds, hour12, timeZone }`), `formatDateTime`. All of them anchor a bare `YYYY-MM-DD` at LOCAL midnight (a naive `new Date('2026-03-05')` is UTC midnight and renders as the previous day west of Greenwich) and take a fallback instead of rendering the literal "Invalid Date". |
| `cronHelpers` | Cron preset list, `isCronExpression` detection, `describeCron` human-readable rendering, and `JOB_INTERVAL_OPTIONS` — the interval-mode cadences for autonomous jobs, mirroring the server's `INTERVAL_OPTIONS`. Import it rather than re-declaring the list in a scheduling component. |
| `markdownText` | `markdownToPlainText(md)` — flatten markdown source to one plain-text string for a clamped preview: strips heading/list/blockquote/fence markers, unwraps emphasis, inline code and links, images → `[alt]`, collapses blank-line runs. Use whenever a card previews arbitrary agent-authored markdown — `line-clamp-N` does not clamp a subtree of block elements, and foreign `##` headings would otherwise join the page's heading outline. Underscore emphasis is word-boundary gated and `__…__` needs interior whitespace, so stack frames and user-agent strings (`10_15_7`, `__init__`) are never silently rewritten. `dropsMarkupWhenFlattened(md)` — did the flatten lose actual markup, as opposed to only normalizing whitespace? Gates a "Show more" disclosure so a short-but-lossy body stays reachable without putting a toggle on every body that merely lost a trailing newline. |
| `timeWindow` | Time-of-day window math (`isInTimeWindow`, `timeStringToMinutes`) and morning-layout auto-switch helpers (`pickActiveLayoutId`, `recordManualLayoutPick`). |
diff --git a/client/src/utils/formatters.js b/client/src/utils/formatters.js
index 7505c16f94..cb5bfd4334 100644
--- a/client/src/utils/formatters.js
+++ b/client/src/utils/formatters.js
@@ -234,7 +234,7 @@ export function timeAgo(dateStr, fallback = 'never') {
}
/**
- * Age of a published thing in whole DAYS — "today", "1 day old", "412 days old".
+ * Age in whole DAYS — "today", "1 day ago", "412 days ago".
*
* Distinct from `timeAgo`, which collapses anything past a month into "3mo ago"
* / "2y ago". Model-download lists want the day count itself: it is the number
@@ -246,12 +246,14 @@ export function timeAgo(dateStr, fallback = 'never') {
*/
export function formatAgeDays(value, fallback = '') {
if (value === null || value === undefined || value === '') return fallback;
- const time = new Date(value).getTime();
+ // toDisplayDate, not `new Date`: a bare "2026-03-05" parses as UTC midnight and
+ // would read a day older than it is everywhere west of Greenwich.
+ const time = toDisplayDate(value).getTime();
if (!Number.isFinite(time)) return fallback;
const days = Math.floor((Date.now() - time) / 86400000);
- // <= 0 covers a clock skew ahead of the publish date — never "-1 days old".
+ // <= 0 covers a clock skew ahead of the publish date — never "-1 days ago".
if (days <= 0) return 'today';
- return `${days.toLocaleString()} day${days === 1 ? '' : 's'} old`;
+ return `${days.toLocaleString()} day${days === 1 ? '' : 's'} ago`;
}
/**
diff --git a/client/src/utils/formatters.test.js b/client/src/utils/formatters.test.js
index 3e14c0366b..b3c8371165 100644
--- a/client/src/utils/formatters.test.js
+++ b/client/src/utils/formatters.test.js
@@ -284,10 +284,16 @@ describe('formatAgeDays', () => {
});
it('counts whole days rather than collapsing into month/year buckets', () => {
- expect(formatAgeDays(daysAgo(1))).toBe('1 day old');
- expect(formatAgeDays(daysAgo(3))).toBe('3 days old');
+ expect(formatAgeDays(daysAgo(1))).toBe('1 day ago');
+ expect(formatAgeDays(daysAgo(3))).toBe('3 days ago');
// timeAgo would say '13mo ago' here — the day count is the point.
- expect(formatAgeDays(daysAgo(412))).toBe('412 days old');
+ expect(formatAgeDays(daysAgo(412))).toBe('412 days ago');
+ });
+
+ it('anchors a bare calendar date at local midnight so it never reads a day older', () => {
+ const today = new Date();
+ const iso = `${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, '0')}-${String(today.getDate()).padStart(2, '0')}`;
+ expect(formatAgeDays(iso)).toBe('today');
});
it('reads a same-day or future-dated publish as today, never a negative count', () => {
diff --git a/server/services/huggingFaceCatalog.js b/server/services/huggingFaceCatalog.js
index 90a4e76367..111d649b17 100644
--- a/server/services/huggingFaceCatalog.js
+++ b/server/services/huggingFaceCatalog.js
@@ -20,6 +20,16 @@ const HF_RETRY_DELAY_MS = 250
// after this budget; in-flight probes keep running and warm the repo cache, so
// the next load (or a recovered HF) enriches without delay.
const CATALOG_ENRICH_TIMEOUT_MS = 5_000
+// Budget for the publish-date lookup behind a checkpoint search. Deliberately
+// longer than CATALOG_ENRICH_TIMEOUT_MS: that bound exists because the curated
+// catalog must stay usable with zero enrichment offline, whereas a search's ages
+// ARE the enrichment, and on a cold cache these probes can sit behind the
+// catalog's own fan-out in the shared gate. Still bounded — a hung Hub must not
+// hold the search open indefinitely.
+const PUBLISH_DATE_BUDGET_MS = 15_000
+// Hard cap on repos probed per publish-date lookup, independent of the caller's
+// page size — abandoned probes keep draining through hfGate after the response.
+const MAX_PUBLISH_DATE_PROBES = 24
const CATEGORY_IDS = new Set(LOCAL_LLM_CATEGORIES.map((c) => c.id))
// Default browse phrases used when the search box is empty (and as the seed when
@@ -1343,8 +1353,14 @@ export function applyMeasuredFit(models, { backend, measured } = {}) {
// Never throws and never fails the caller's list: a repo the Hub has no answer
// for (gated, renamed, offline) resolves to `null`, which the UI renders as a
// missing age rather than an error.
-export async function fetchRepoPublishedDates(repoIds = [], { timeoutMs = CATALOG_ENRICH_TIMEOUT_MS } = {}) {
+export async function fetchRepoPublishedDates(repoIds = [], { timeoutMs = PUBLISH_DATE_BUDGET_MS } = {}) {
+ // Cap the fan-out independently of the caller's page size. The MTPLX search
+ // endpoint accepts limit=100, and every unresolved probe keeps draining through
+ // the shared hfGate after the response returns — starving curated-catalog and
+ // HF-search enrichment on a degraded Hub for as long as it takes. A page of
+ // ages beyond the first two dozen rows is not worth that.
const unique = [...new Set(repoIds.filter((id) => typeof id === 'string' && id.includes('/')))]
+ .slice(0, MAX_PUBLISH_DATE_PROBES)
// Seeded with nulls and filled in place, so the budget below can return early
// with a partial answer instead of an empty one.
const dates = Object.fromEntries(unique.map((repo) => [repo, null]))
@@ -1352,11 +1368,11 @@ export async function fetchRepoPublishedDates(repoIds = [], { timeoutMs = CATALO
const model = await fetchRepoModel(repo)
dates[repo] = model?.createdAt || model?.created_at || null
}))
- // Bound the wait exactly as enrichCatalogWithVariants does: a listing of 24
- // repos is 6 rounds through a gate of 4, each round up to the 12s fetch budget
- // plus a retry, so an unreachable Hub would otherwise turn an instant search
- // into a minute-long hang. Whatever resolved in time is already in `dates`; the
- // rest stay null and their probes keep warming the repo cache for the next search.
+ // Bound the wait the way enrichCatalogWithVariants does, so an unreachable Hub
+ // can never hang a search. Whatever resolved in time is already in `dates`; the
+ // rest stay null and the card simply omits that row's age. Note a TRANSIENT
+ // failure caches nothing (see fetchRepoModel), so those repos are re-probed on
+ // the next search rather than being remembered as dateless.
if (timeoutMs > 0) {
let timer
const budget = new Promise((resolve) => { timer = setTimeout(resolve, timeoutMs); timer.unref?.() })
diff --git a/server/services/huggingFaceCatalog.test.js b/server/services/huggingFaceCatalog.test.js
index ce512eef97..317c4ef479 100644
--- a/server/services/huggingFaceCatalog.test.js
+++ b/server/services/huggingFaceCatalog.test.js
@@ -1329,13 +1329,30 @@ describe('fetchRepoPublishedDates', () => {
})
})
- it('returns a partial answer rather than hanging the caller when the Hub stalls', async () => {
+ it('returns the dates that arrived in time rather than hanging the caller when the Hub stalls', async () => {
// A listing of two dozen repos is several rounds through the shared gate, so an
- // unresponsive Hub must not hold the search open — unanswered repos come back null.
- fetch.mockImplementation(() => new Promise(() => {}))
+ // unresponsive Hub must not hold the search open. What matters is that the repos
+ // that DID answer keep their dates — dropping them on timeout would leave a whole
+ // page of rows ageless because one repo hung.
+ fetch.mockImplementation(async (url) => (
+ String(url).includes('pub-owner/Fast')
+ ? response({ modelId: 'pub-owner/Fast', createdAt: '2026-01-02T00:00:00.000Z' })
+ : new Promise(() => {})
+ ))
+
+ expect(await fetchRepoPublishedDates(['pub-owner/Fast', 'pub-owner/Slow'], { timeoutMs: 50 }))
+ .toEqual({ 'pub-owner/Fast': '2026-01-02T00:00:00.000Z', 'pub-owner/Slow': null })
+ })
+
+ it('caps the fan-out so one oversized page cannot flood the shared Hub gate', async () => {
+ fetch.mockImplementation(async () => response({ createdAt: '2026-01-02T00:00:00.000Z' }))
+ const repos = Array.from({ length: 40 }, (_, i) => `pub-owner/Repo${i}`)
+
+ const dates = await fetchRepoPublishedDates(repos)
- expect(await fetchRepoPublishedDates(['pub-owner/Slow'], { timeoutMs: 20 }))
- .toEqual({ 'pub-owner/Slow': null })
+ // 24 probed; the rest are simply absent rather than queued behind the gate.
+ expect(Object.keys(dates)).toHaveLength(24)
+ expect(fetch).toHaveBeenCalledTimes(24)
})
it('ignores ids that are not owner/name rather than asking the Hub about them', async () => {