diff --git a/frontend/src/index.css b/frontend/src/index.css index 03af0dd..321b48c 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -1366,6 +1366,9 @@ body.chips-dragging *{cursor:inherit} metric family — it is not a measurement, it is a judgment about them. Each row is a question and the answer with its probability, and the probability is a smaller, dimmer line on purpose: the claim and how sure the model was must not read as the same weight. */ +/* The receipt line under the range control: dimmer and closer to the caption above it than to the + cards, because it is an answer to "why has nothing moved", not a measurement. */ +.vh-sync{margin:-6px 2px 12px;line-height:1.45} .ins-card{--tint:var(--acc);padding:12px 14px 14px;margin-bottom:12px} .ins-hd{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:4px} .ins-t{display:flex;align-items:center;gap:6px;font-size:14px;font-weight:600;color:var(--tint)} diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.js index f143026..39d379f 100644 --- a/frontend/src/locales/es.js +++ b/frontend/src/locales/es.js @@ -1482,6 +1482,9 @@ export default { 'the last {0} days': 'últimos {0} días', 'the last year': 'último año', 'updated {0}': 'actualizado {0}', + 'No sync has arrived yet. If the automation is set up, run Manual Sync once in Health Auto Export.': 'Todavía no llegó ningún envío. Si ya configuraste la automatización, corré Manual Sync una vez en Health Auto Export.', + 'The last sync brought {0} new datapoints, {1} were already stored.': 'El último envío trajo {0} datos nuevos; {1} ya estaban guardados.', + 'The last sync brought nothing new: every datapoint was already stored. The phone is sending — Apple Health has nothing more recent than what is already here.': 'El último envío no trajo nada nuevo: todos los datos ya estaban guardados. El teléfono está enviando; Apple Health no tiene nada más reciente que lo que ya está acá.', 'Nothing has come in today yet — this is the latest reading of each metric.': 'Todavía no llegó nada de hoy: esto es la última lectura de cada métrica.', 'low {0}': 'mín {0}', 'avg {0}': 'media {0}', diff --git a/frontend/src/views/Health.jsx b/frontend/src/views/Health.jsx index ae842b7..229bfc2 100644 --- a/frontend/src/views/Health.jsx +++ b/frontend/src/views/Health.jsx @@ -522,6 +522,8 @@ export default function Health() { // twice in two different sizes (see the note above the sheets). const groups = groupedCards(cards) const workouts = workoutRows(data, { limit: 20 }) + // The receipt of the last ingest, as the endpoint reports it: `{ts, metrics, points, duplicates}`. + const lastIngest = data?.last && data.last.ts ? data.last : null // Everything the card draws, or null when nothing has been asked yet. const view = insightView(ins?.insight, data) const last = data?.last?.ts @@ -560,6 +562,20 @@ export default function Health() { {last ? ' · ' + t('updated {0}', agoLabel(last)) : ''} + {/* What the last sync actually brought. + A card that has not moved and a phone that is not sending look identical on this screen, + and they need opposite fixes — so the receipt the endpoint already returns (how many + datapoints arrived, how many were already stored) is shown instead of left in the api + response. "Nothing new" and "nothing at all" are different sentences, and saying which one + it is costs one line. */} +
+ {!lastIngest + ? t('No sync has arrived yet. If the automation is set up, run Manual Sync once in Health Auto Export.') + : lastIngest.points > 0 + ? t('The last sync brought {0} new datapoints, {1} were already stored.', lastIngest.points, lastIngest.duplicates || 0) + : t('The last sync brought nothing new: every datapoint was already stored. The phone is sending — Apple Health has nothing more recent than what is already here.')} +
+ {fellBack &&
{t('Nothing has come in today yet — this is the latest reading of each metric.')}
} diff --git a/frontend/src/views/Health.render.test.jsx b/frontend/src/views/Health.render.test.jsx index ad62319..65ce23e 100644 --- a/frontend/src/views/Health.render.test.jsx +++ b/frontend/src/views/Health.render.test.jsx @@ -138,6 +138,38 @@ describe('Salud', () => { expect(cards().every(e => e.getAttribute('style').includes('--tint'))).toBe(true) }) + /* The line that answers "why has nothing moved". A phone that is sending and a phone that is not + look identical on this screen, and they need opposite fixes, so the endpoint's own receipt is + shown: how many datapoints the last sync brought and how many were already stored. */ + it('says what the last sync brought, including when it brought nothing new', async () => { + const withLast = (points, duplicates) => ({ ...VITALS, last: { ts: Date.now() - 12 * 60000, metrics: 4, points, duplicates, workouts: 0 } }) + api.mockResolvedValue(withLast(6, 282)) + await mount() + expect(host.querySelector('.vh-sync').textContent).toContain('brought 6 new datapoints, 282 were already stored') + + // Everything a repeat: the phone is working, and Health has nothing newer. That is a different + // sentence from "nothing arrived", and it is the one that sends somebody to the Watch instead. + const refresh = () => act(async () => { host.querySelector('button[aria-label="Refresh"]').dispatchEvent(new MouseEvent('click', { bubbles: true })) }) + api.mockResolvedValue(withLast(0, 288)) + await refresh() + await act(async () => {}) + const line = host.querySelector('.vh-sync').textContent + expect(line).toContain('nothing new') + expect(line).toContain('The phone is sending') + expect(line).not.toContain('No sync has arrived yet') + + // ...and the refresh button is what did it: the screen re-reads what the server has. + expect(api.mock.calls.filter(c => c[0] === '/api/vitals?days=7').length).toBe(2) + }) + + it('asks for a manual sync when a profile has metrics but no receipt', async () => { + // A hand-written or migrated file can hold metrics with no `last` at all; the line says so + // instead of printing a zero receipt that would look like a sync that brought nothing. + api.mockResolvedValue({ ...VITALS, last: null }) + await mount() + expect(host.querySelector('.vh-sync').textContent).toContain('No sync has arrived yet') + }) + it('offers the setup steps instead of a blank screen when nothing has arrived', async () => { api.mockResolvedValue({ ok: true, days: 30, key: null, updatedAt: 0, last: null, metrics: {}, workouts: [] }) await mount()