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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
show a model's age in days on the Hugging Face download lists
[._.]/ Adam Eivy6dd5454e3a1b
diff --git a/client/src/components/settings/LocalLlmTab.jsx b/client/src/components/settings/LocalLlmTab.jsxindex 4011945f62..34c08e142f 100644--- a/client/src/components/settings/LocalLlmTab.jsx+++ b/client/src/components/settings/LocalLlmTab.jsx@@ -4,7 +4,7 @@ import { Cpu, Box, ArrowRightLeft, Download, Trash2, RefreshCw, Search, Plus, Eximport toast from '../ui/Toast';import ConfirmButtonPair from '../ui/ConfirmButtonPair';import BrailleSpinner from '../BrailleSpinner';-import { formatBytes, formatContextLength, timeAgo, recommendedRamGb, formatDateNumeric } from '../../utils/formatters';+import { formatAgeDays, formatBytes, formatContextLength, timeAgo, recommendedRamGb, formatDateNumeric } from '../../utils/formatters';import { localLlmTargetKey } from '../../lib/localLlmTargetKey';import { useConfirmDelete } from '../../hooks/useConfirmDelete';import {@@ -1830,7 +1830,7 @@ export function LocalLlmTab() {<spantitle={`Published ${formatDateNumeric(createdMs)}${Number.isFinite(updatedMs) ? ` · updated ${timeAgo(m.updatedAt)}` : ''}`}>- published {timeAgo(m.createdAt)}+ {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.jsxindex 2c21eaebbc..036e46516a 100644--- a/client/src/components/settings/MtplxCheckpoints.jsx+++ b/client/src/components/settings/MtplxCheckpoints.jsx@@ -4,7 +4,7 @@ import BrailleSpinner from '../BrailleSpinner';import ConfirmButtonPair from '../ui/ConfirmButtonPair';import ProgressBar from '../ui/ProgressBar';import { useConfirmDelete } from '../../hooks/useConfirmDelete';-import { formatBytes } from '../../utils/formatters';+import { formatAgeDays, formatBytes, formatDateNumeric } from '../../utils/formatters';/*** MTPLX checkpoint manager — search, download, and remove MTP model weights.@@ -215,6 +215,7 @@ export default function MtplxCheckpoints({<ul className="space-y-1.5 max-h-72 overflow-y-auto">{results.map((row) => {const installed = cachedRepos.has(row.repo);+ const age = formatAgeDays(row.publishedAt);return (<li key={row.repo} className="flex flex-col sm:flex-row sm:items-center gap-2 bg-port-bg border border-port-border rounded-lg px-3 py-2"><div className="min-w-0 flex-1">@@ -222,6 +223,9 @@ export default function MtplxCheckpoints({<p className="text-[11px] text-gray-500 truncate">{row.repo}{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>}{row.license ? ` · ${row.license}` : ''}</p></div>diff --git a/client/src/utils/README.md b/client/src/utils/README.mdindex ba173f56c4..7371a43770 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`, `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 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". || `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.jsindex 636133eb8c..ab902e49bd 100644--- a/client/src/utils/formatters.js+++ b/client/src/utils/formatters.js@@ -233,6 +233,27 @@ export function timeAgo(dateStr, fallback = 'never') {return `${Math.floor(days / 365)}y ago`;}+/**+ * Age of a published thing in whole DAYS — "today", "1 day old", "412 days old".+ *+ * 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+ * that says how current a checkpoint is, and a bucket label hides the difference+ * between a 40-day-old release and a 400-day-old one.+ * @param {string|number|Date|null} value - ISO timestamp, epoch ms, or Date+ * @param {string} fallback - Text for null/missing/unparseable values+ * @returns {string} Day-count label+ */+export function formatAgeDays(value, fallback = '') {+ if (value === null || value === undefined || value === '') return fallback;+ const time = new Date(value).getTime();+ if (!Number.isFinite(time)) return fallback;+ const days = Math.floor((Date.now() - time) / 86400000);+ if (days < 0) return 'today'; // A clock skew ahead of the publish date is not "-1 days old".+ if (days === 0) return 'today';+ return `${days.toLocaleString()} day${days === 1 ? '' : 's'} old`;+}+/*** Format a future timestamp as a relative "in X" string, mirroring timeAgo's* bucket thresholds. Returns `fallback` for null/missing or past dates (usediff --git a/client/src/utils/formatters.test.js b/client/src/utils/formatters.test.jsindex ec188fc318..3e14c0366b 100644--- a/client/src/utils/formatters.test.js+++ b/client/src/utils/formatters.test.js@@ -1,6 +1,6 @@import { describe, it, expect } from 'vitest';import {- clamp, formatContextLength, formatDurationMin, formatDurationMs, formatEventDateTime, timeAgo,+ clamp, formatContextLength, formatDurationMin, formatDurationMs, formatEventDateTime, timeAgo, formatAgeDays,formatCooldown, recommendedRamGb, parseTimeoutMs, formatDurationSec, middleTruncate,formatWeight, formatPercent, formatUsd, formatBytes,formatDateNumeric, formatTimeOfDaySeconds, formatClockTime, formatWeekdayDate,@@ -274,6 +274,28 @@ describe('timeAgo', () => {});});+describe('formatAgeDays', () => {+ const daysAgo = (d) => new Date(Date.now() - d * 24 * 3600 * 1000).toISOString();++ it('returns the fallback for a missing or unparseable value', () => {+ expect(formatAgeDays(null)).toBe('');+ expect(formatAgeDays('', 'unknown')).toBe('unknown');+ expect(formatAgeDays('not-a-date', '—')).toBe('—');+ });++ 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');+ // timeAgo would say '13mo ago' here — the day count is the point.+ expect(formatAgeDays(daysAgo(412))).toBe('412 days old');+ });++ it('reads a same-day or future-dated publish as today, never a negative count', () => {+ expect(formatAgeDays(new Date().toISOString())).toBe('today');+ expect(formatAgeDays(new Date(Date.now() + 3600 * 1000).toISOString())).toBe('today');+ });+});+describe('formatCooldown', () => {it('formats 0 ms as 0:00', () => {expect(formatCooldown(0)).toBe('0:00');diff --git a/server/services/huggingFaceCatalog.js b/server/services/huggingFaceCatalog.jsindex dba0d58000..5ae8f41810 100644--- a/server/services/huggingFaceCatalog.js+++ b/server/services/huggingFaceCatalog.js@@ -1331,3 +1331,23 @@ export function applyMeasuredFit(models, { backend, measured } = {}) {}return list}++// Publish dates for a set of Hugging Face repos, as `{ repoId: createdAt|null }`.+//+// For lists whose rows come from somewhere OTHER than the Hub's own search — the+// MTPLX discover listing, which carries downloads and license but no dates — so+// the card can say how old a checkpoint is. Reuses fetchRepoModel's three tiers+// (memory → disk → Hub) and its gate, so a repeated search is free and a burst+// stays inside the same concurrency budget as everything else here.+//+// 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 = []) {+ const unique = [...new Set(repoIds.filter((id) => typeof id === 'string' && id.includes('/')))]+ const settled = await Promise.allSettled(unique.map((repo) => fetchRepoModel(repo)))+ return Object.fromEntries(unique.map((repo, i) => {+ const model = settled[i].status === 'fulfilled' ? settled[i].value : null+ return [repo, model?.createdAt || model?.created_at || null]+ }))+}diff --git a/server/services/huggingFaceCatalog.test.js b/server/services/huggingFaceCatalog.test.jsindex a8e019da87..08a8bcc40a 100644--- a/server/services/huggingFaceCatalog.test.js+++ b/server/services/huggingFaceCatalog.test.js@@ -1,5 +1,5 @@import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'-import { searchHuggingFaceModels, enrichCatalogWithVariants, applyMeasuredFit } from './huggingFaceCatalog.js'+import { searchHuggingFaceModels, enrichCatalogWithVariants, applyMeasuredFit, fetchRepoPublishedDates } from './huggingFaceCatalog.js'import { __resetOllamaRegistryCache } from './ollamaRegistryCatalog.js'// The disk cache resolves its file from the REAL PATHS.data, and fetchRepoModel@@ -1312,6 +1312,29 @@ describe('huggingFaceCatalog', () => {})})+describe('fetchRepoPublishedDates', () => {+ beforeEach(() => { vi.stubGlobal('fetch', vi.fn()) })+ afterEach(() => { vi.unstubAllGlobals() })++ it('returns each repo\'s publish date, and null for one the Hub cannot answer for', async () => {+ fetch.mockImplementation(async (url) => (+ String(url).includes('pub-owner/Dated')+ ? response({ modelId: 'pub-owner/Dated', createdAt: '2026-01-02T00:00:00.000Z' })+ : { ok: false, status: 404, json: vi.fn(async () => null), text: vi.fn(async () => 'not found') }+ ))++ expect(await fetchRepoPublishedDates(['pub-owner/Dated', 'pub-owner/Gone'])).toEqual({+ 'pub-owner/Dated': '2026-01-02T00:00:00.000Z',+ 'pub-owner/Gone': null+ })+ })++ it('ignores ids that are not owner/name rather than asking the Hub about them', async () => {+ expect(await fetchRepoPublishedDates(['not-a-repo', null, 42])).toEqual({})+ expect(fetch).not.toHaveBeenCalled()+ })+})+describe('applyMeasuredFit', () => {// Ollama's HF install ids and the assessment's recorded model id are the same// string modulo case and a `:latest` tag, so matching must go through the samediff --git a/server/services/mtplxModelManager.js b/server/services/mtplxModelManager.jsindex 37d89518b0..f58f4ccec2 100644--- a/server/services/mtplxModelManager.js+++ b/server/services/mtplxModelManager.js@@ -26,6 +26,7 @@ import { ServerError } from '../lib/errorHandler.js';import { safeJSONParse } from '../lib/fileUtils.js';import { listMtplxCachedModels } from '../lib/mtplxModels.js';import { findCommandOnPath } from '../lib/processEnv.js';+import { fetchRepoPublishedDates } from './huggingFaceCatalog.js';import { runStreamingCommand } from '../lib/streamingSpawn.js';/** A Hugging Face search is one API call — short, and worth failing fast. */@@ -109,18 +110,25 @@ export async function searchMtplxCatalog({ query = '', limit = 24, offset = 0 }const parsed = start === -1 ? null : safeJSONParse(text.slice(start), null, { allowArray: true });if (!Array.isArray(parsed)) return { models: [], error: '`mtplx forge discover --json` did not return a model list' };- return {- models: parsed- .filter((row) => typeof row?.repo === 'string' && row.repo)- .map((row) => ({- repo: row.repo,- name: row.branded_name || row.repo.split('/').pop(),- owner: row.owner || row.repo.split('/')[0],- downloads: Number.isFinite(row.downloads) ? row.downloads : null,- license: row.license || null,- })),- error: null,- };+ const models = parsed+ .filter((row) => typeof row?.repo === 'string' && row.repo)+ .map((row) => ({+ repo: row.repo,+ name: row.branded_name || row.repo.split('/').pop(),+ owner: row.owner || row.repo.split('/')[0],+ downloads: Number.isFinite(row.downloads) ? row.downloads : null,+ license: row.license || null,+ }));++ // `mtplx forge discover` reports downloads and license but no dates, and how+ // OLD a checkpoint is decides whether it is worth a multi-gigabyte pull. Ask+ // the Hub itself for the publish date — cached per repo, so a repeated search+ // is free — and leave `publishedAt: null` when the Hub has no answer rather+ // than failing a search that is otherwise complete.+ const published = await fetchRepoPublishedDates(models.map((m) => m.repo));+ for (const model of models) model.publishedAt = published[model.repo] || null;++ return { models, error: null };}/**diff --git a/server/services/mtplxModelManager.test.js b/server/services/mtplxModelManager.test.jsindex 2f1af72155..c504faff7b 100644--- a/server/services/mtplxModelManager.test.js+++ b/server/services/mtplxModelManager.test.js@@ -10,6 +10,7 @@ import * as bufferedSpawnModule from '../lib/bufferedSpawn.js';import * as mtplxModels from '../lib/mtplxModels.js';import * as processEnv from '../lib/processEnv.js';import * as streamingSpawn from '../lib/streamingSpawn.js';+import * as hfCatalog from './huggingFaceCatalog.js';const BINARY = '/opt/homebrew/bin/mtplx';@@ -20,6 +21,8 @@ describe('mtplxModelManager', () => {vi.restoreAllMocks();vi.spyOn(processEnv, 'findCommandOnPath').mockReturnValue(BINARY);vi.spyOn(mtplxModels, 'listMtplxCachedModels').mockResolvedValue({ models: [], error: null });+ // Publish dates come from the Hub — no suite may reach it.+ vi.spyOn(hfCatalog, 'fetchRepoPublishedDates').mockResolvedValue({});vi.spyOn(console, 'log').mockImplementation(() => {});vi.spyOn(console, 'error').mockImplementation(() => {});});@@ -50,7 +53,7 @@ describe('mtplxModelManager', () => {const result = await searchMtplxCatalog({});expect(result).toEqual({- models: [{ repo: 'Example/Qwen-MTP', name: 'Qwen MTP', owner: 'Example', downloads: 42, license: 'apache-2.0' }],+ models: [{ repo: 'Example/Qwen-MTP', name: 'Qwen MTP', owner: 'Example', downloads: 42, license: 'apache-2.0', publishedAt: null }],error: null,});// An empty `--query ''` would search for the empty string instead of@@ -74,6 +77,21 @@ describe('mtplxModelManager', () => {expect(await searchMtplxCatalog({})).toEqual({ models: [], error: 'error: huggingface.co unreachable' });});+ it("carries each repo's Hub publish date so a card can say how old the checkpoint is", async () => {+ vi.spyOn(bufferedSpawnModule, 'bufferedSpawn').mockResolvedValue(spawnOk(JSON.stringify([+ { repo: 'Example/Qwen-MTP', downloads: 42 },+ { repo: 'Example/Unlisted', downloads: 1 },+ ])));+ hfCatalog.fetchRepoPublishedDates.mockResolvedValue({ 'Example/Qwen-MTP': '2026-01-02T00:00:00.000Z' });++ const { models } = await searchMtplxCatalog({});++ expect(models[0].publishedAt).toBe('2026-01-02T00:00:00.000Z');+ // A repo the Hub has no answer for still lists — the card just omits the age.+ expect(models[1].publishedAt).toBeNull();+ expect(hfCatalog.fetchRepoPublishedDates).toHaveBeenCalledWith(['Example/Qwen-MTP', 'Example/Unlisted']);+ });+it('refuses before spawning when MTPLX is not installed', async () => {processEnv.findCommandOnPath.mockReturnValue(null);await expect(searchMtplxCatalog({})).rejects.toThrow(/not found on PATH/);