Date-stamp message timestamps that aren't from today - #140
Merged
Conversation
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.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Timestamps rendered time-only everywhere, so a
09:15from this morning and a09:15from three days ago read identically. Messages from today keep the bare time; anything older now readsAug 5, 21:40.Covers all four surfaces:
/displaykiosk 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.timestampis 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.ChatEntrygains an optional raw ISOtsnext to the existing string.timestampstays as the fallback, so pre-existing entries and test fixtures render unchanged.useDayKeyre-renders the message surfaces on the local midnight boundary (setTimeoutto the boundary, not polling).rx_messageframes carry no serverts— only history is stamped (backend/server.py:487) — so the client records arrival time for those.toLocaleTimeStringbodies collapse into oneutils/datetimehelper.padHourpreserves 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 newutils/__tests__/datetime.test.tscases (same day, previous day, year boundary, bothpadHourmodes, missing/unparseable input, both backend ISO flavors). Fixed injectednow, never the system clock.Not yet done: eyeballing the four surfaces in a running app (including e-ink mode) and the midnight-rollover check.