From 426f975d9cbfe2ed4613e9edf42af7a7d1614341 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Sun, 26 Jul 2026 22:13:30 -0400 Subject: [PATCH] Records: default to newest first on the source's date field The page loaded unsorted, so the most recent rows were rarely on screen. On source change it now looks up the source's first date-typed field and sorts descending on it, falling back to unsorted when a source has no date field. Co-Authored-By: Claude Opus 5 --- ui/src/pages/Records.jsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ui/src/pages/Records.jsx b/ui/src/pages/Records.jsx index a5eb472..09d0940 100644 --- a/ui/src/pages/Records.jsx +++ b/ui/src/pages/Records.jsx @@ -119,7 +119,14 @@ export default function Records({ source }) { setPanelOpen(false) setOverrideCols([]) setExtraCols([]) - load(0, null, 'asc', []) + // Default to newest first on the source's first date field, if it has one + api.getSource(source) + .then(src => (src?.config?.fields || []).find(f => f.type === 'date')?.name || null) + .catch(() => null) + .then(dateCol => { + if (dateCol) setSort({ col: dateCol, dir: 'desc' }) + load(0, dateCol, 'desc', []) + }) api.getOverrideKeys(source).then(setOverrideCols).catch(() => {}) api.getGlobalValues().then(setGlobalValues).catch(() => {}) setSelected(new Set())