Skip to content

Date-stamp message timestamps that aren't from today - #140

Merged
Xpiatio merged 1 commit into
masterfrom
feat/message-date-stamps
Aug 6, 2026
Merged

Date-stamp message timestamps that aren't from today#140
Xpiatio merged 1 commit into
masterfrom
feat/message-date-stamps

Conversation

@Xpiatio

@Xpiatio Xpiatio commented Aug 6, 2026

Copy link
Copy Markdown
Owner

What

Timestamps rendered time-only everywhere, so a 09:15 from this morning and a 09:15 from three days ago read identically. Messages from today keep the bare time; anything older now reads Aug 5, 21:40.

Covers all four surfaces: /display kiosk chat, Neighborhood alerts + incident log, main operator chat log, Family panel "Last OK".

How

The label has to be computed at render time rather than baked at ingest. ChatEntry.timestamp is a string built once when the WS frame arrives, so a line logged at 23:50 would keep claiming "today" after midnight on an always-on display.

  • ChatEntry gains an optional raw ISO ts next to the existing string. timestamp stays as the fallback, so pre-existing entries and test fixtures render unchanged.
  • New useDayKey re-renders the message surfaces on the local midnight boundary (setTimeout to the boundary, not polling).
  • Live rx_message frames carry no server ts — only history is stamped (backend/server.py:487) — so the client records arrival time for those.
  • The five copy-pasted toLocaleTimeString bodies collapse into one utils/datetime helper. padHour preserves each caller's existing hour style, so nothing changes visually beyond the added date.

Deliberately out of scope: no 12/24-hour or timezone preference (none exists today), and the NCS plugin roster (epoch seconds, not ISO) is untouched.

Testing

  • npx tsc -p tsconfig.build.json --noEmit — clean.
  • npx vitest run — 76 files / 1151 tests pass, including 10 new utils/__tests__/datetime.test.ts cases (same day, previous day, year boundary, both padHour modes, missing/unparseable input, both backend ISO flavors). Fixed injected now, never the system clock.

Not yet done: eyeballing the four surfaces in a running app (including e-ink mode) and the midnight-rollover check.

Timestamps rendered time-only everywhere, so a 09:15 from this morning
and a 09:15 from three days ago read identically in a scrollback, on the
kiosk wall, and in the neighborhood log.

Messages from today keep the bare time; anything older now reads
"Aug 5, 21:40".

The label has to be computed at render time rather than baked at ingest:
ChatEntry.timestamp is a string built once when the WS frame arrives, so
a line logged at 23:50 would keep claiming "today" after midnight on an
always-on display. ChatEntry gains an optional raw ISO `ts` alongside the
existing string (kept as a fallback so older entries and fixtures still
render), and useDayKey re-renders the message surfaces on the local
midnight boundary.

Live rx_message frames carry no server ts — only history is stamped — so
the client records arrival time for those.

Also folds the five copy-pasted toLocaleTimeString bodies into one
utils/datetime helper. padHour preserves each caller's existing hour
style, so nothing changes visually beyond the added date.
@Xpiatio
Xpiatio merged commit 7fcf6b8 into master Aug 6, 2026
1 check passed
@Xpiatio
Xpiatio deleted the feat/message-date-stamps branch August 6, 2026 23:48
@Xpiatio Xpiatio mentioned this pull request Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant