Salud: decir qué trajo el último envío, porque "no se mueve" son dos problemas
Tests / test (push) Canceled after 0s
Publish Docker images / build (., ./web/Dockerfile, web) (push) Canceled after 0s
Publish Docker images / build (./api, ./api/Dockerfile, api) (push) Canceled after 0s

"No se están moviendo los datos de la tarjeta, se quedan igual." En esta pantalla, un teléfono que
está enviando cada cinco minutos y uno que dejó de enviar se ven idénticos: los mismos números, la
misma hora de la última lectura. Necesitan arreglos opuestos — uno se mira en el reloj, el otro en el
celular — y hasta ahora la pantalla no daba con qué distinguirlos: decía "actualizado hace X", que es
cuando llegó el último envío, y nada sobre lo que ese envío traía.

El endpoint ya devolvía el recibo (`last: {ts, points, duplicates, workouts}`) y se quedaba en la
respuesta. Ahora se muestra:

  · "El último envío trajo 6 datos nuevos; 282 ya estaban guardados." → el teléfono trabaja y los
    números se mueven cuando Apple Health tiene algo nuevo.
  · "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á." → el problema está en
    el reloj o en su sincronización con Salud, no en la app ni en el servidor.
  · "Todavía no llegó ningún envío." → la automatización no corrió nunca.

Tres frases que llevan a tres lugares distintos, en una línea bajo el rango. Antes de sospechar del
merge, esto dice si hay algo que mergear.

El test usa el propio botón de actualizar para forzar la segunda lectura, así que también comprueba
que ese botón vuelve a preguntarle al servidor. Mutation-check: si el recibo pierde el caso "nada
nuevo", falla.
This commit is contained in:
dsantillan committed 2026-09-23 17:31:28 -04:00
1 parent 52d1a05426
commit 81301523ab
4 files changed
+54

No files matched your search

+3
View File
@@ -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)}
+3
View File
@@ -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}',
+16
View File
@@ -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)) : ''}
</div>
{/* 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. */}
<div className="small dim vh-sync">
{!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.')}
</div>
{fellBack && <div className="small dim" style={{ margin: '0 2px 12px', lineHeight: 1.5 }}>
{t('Nothing has come in today yet — this is the latest reading of each metric.')}
</div>}
+32
View File
@@ -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()