Now panel: show day's high + its feels-like, and peak rain chance with time

Was showing right-now's temp/feels-like/rain% under a headline that's
already a whole-day summary -- mismatched framing (a day-level
headline next to point-in-time numbers).

- Big temp is now today's forecast high, with a small 'High' label.
- Feels-like is paired with that same high-temp hour, not right now.
- Rain% is the day's peak chance, shown as 'X% chance of rain around
  HH:00' instead of the current hour's (often much lower) number.

summarizeToday() now returns highTemp/highFeelsLike/rainChance
alongside the existing headline/note/umbrella, computed from the same
already-fetched hourly points. Frontend falls back to currentPoint's
own values only if summary is unexpectedly null.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-08-31 11:56:43 +00:00
parent 997ea817cb
commit 335e6e31a8
4 changed files with 47 additions and 7 deletions

View file

@ -31,8 +31,17 @@ export function summarizeToday(points, nowHour) {
// replaces) — an hour's icon can be non-rain while it still carries a real, if
// slim, numeric chance. Worth surfacing in the headline rather than a flat "Dry"
// that silently disagrees with a "5%" sitting right there on an hour card.
const precipValues = points.map(p => p.precip_prob).filter(v => v != null)
const maxPrecip = precipValues.length ? Math.max(...precipValues) : null
// Keep the whole peak point, not just the number, so the "now" panel can show
// *when* that peak chance falls ("30% chance of rain around 15:00") rather
// than whatever the current hour's own (possibly much lower) number is.
const rainPeakPoint = points.reduce((best, p) =>
p.precip_prob != null && (!best || p.precip_prob > best.precip_prob) ? p : best, null)
const maxPrecip = rainPeakPoint?.precip_prob ?? null
// Day's high, and the feels-like *for that same hour* — pairing "feels like"
// with the temp it actually describes, rather than the current hour's feels
// like sitting next to a headline high from a different time of day.
const highPoint = points.reduce((max, p) => (p.temp_c > max.temp_c ? p : max), points[0])
const laterPoints = points.filter(p => hourOf(p) >= nowHour)
const earlierPoints = points.filter(p => hourOf(p) < nowHour)
@ -67,7 +76,14 @@ export function summarizeToday(points, nowHour) {
// Umbrella nudge: real rain chance either right now or coming up later today.
const umbrella = laterWetFraction > 0.25 || rainFraction > 0.25
return { headline, note, umbrella }
return {
headline,
note,
umbrella,
highTemp: highPoint.temp_c,
highFeelsLike: highPoint.feels_like_c,
rainChance: rainPeakPoint ? { prob: rainPeakPoint.precip_prob, ts: rainPeakPoint.ts } : null,
}
}
function hourOf(point) {