Skip to content

fix(console): « 2 h ago » across midnight, and the Sites spec reads moments on a fixed clock (FRU-270) - #314

Merged
sakuga-agent[bot] merged 1 commit into
mainfrom
fru-sf-workspace/fru-270-ago-at-midnight
Oct 13, 2026
Merged

sakuga-agent[bot] merged 1 commit into
mainfrom
fru-sf-workspace/fru-270-ago-at-midnight

Conversation

@sakuga-agent

@sakuga-agent sakuga-agent Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Not critical: one helper of the console and one spec. Follow-up of #302. Urgent: e2e/console-sites.spec.ts fails on main between 00:00 and 02:00 (expected « 2 h ago », received « Yesterday »).

Two causes, both fixed

  1. The spec counted its moments from the clock of the machine. It now counts them back from noon of a fixed day (NOON). The test that reads moments sets the clock of the browser there (page.clock.setFixedTime).
  2. The product: ago() counted by the day of the calendar from the first hour. A note of 22:30 read at 00:30 said « Yesterday ». The rule now, the more natural one: hours for the 24 hours before (« 2 h ago » … « 23 h ago »), then by the day of the calendar (« Yesterday », « 3 days ago » for the week, then the date).

Proof

  • A new case, « the last note is counted in hours for a whole day, across midnight, then by the calendar ». At 00:30 on a fixed clock: 22:30 reads « 2 h ago », midnight the day before reads « Yesterday », 23:30 two days before reads « 2 days ago ». With the ago.ts of main it fails (received « Yesterday »).
  • ago.test.ts: 22:30 at 00:30 is « 2 h ago », 01:00 the day before is « 23 h ago », past 24 hours is « Yesterday » or « 2 days ago » by the calendar.
  • Locally: console-sites 18 passed, console unit tests 117 passed.

No sentence is added: « {count} h ago », « Yesterday » and « {count} days ago » are on main with their French.

#313 (the Notes page, stacked on #306) carries the same fix to the clock of the spec. I will put it on top of this once this is merged.

🤖 Generated with Claude Code


Sakuga Review · Score de confiance : 4/5

Le changement de logique dans ago.ts est correct et peut être fusionné ; un risque de test à vérifier avant fusion, car le nouveau défaut de since() peut faire échouer des specs qui ne fixent pas l'horloge.

Constats

  1. P2 since() ancre les dates sur NOON sans fixer l'horloge partout e2e/console-sites.spec.ts:46
    since() calcule désormais à partir de NOON (13 oct. 2026) au lieu de Date.now(). Un test qui appelle since() sans page.clock.setFixedTime affiche des moments relatifs à l'horloge réelle, bien plus tard que NOON : une note de 12 minutes s'affiche alors en jours ou en date, et une assertion « 12 min ago » échoue. Le diff ne montre pas les autres tests du fichier, donc je ne peux pas confirmer. Correction : Fixer l'horloge dans chaque test qui lit un moment, ou revenir à Date.now() comme défaut de since() et ne passer NOON qu'aux tests qui fixent l'horloge.
Résumé

Le changement affiche les heures pour les 24 dernières heures, puis compte les jours calendaires, et corrige « Hier » passé minuit. J'ai vérifié les bornes de ago.ts (moins de 24 h, un jour calendaire, plus de sept jours, moment futur) : elles sont correctes. Le spec e2e fixe l'horloge du navigateur pour les nouveaux cas, mais since() prend désormais NOON par défaut, ce qui peut casser des tests qui ne fixent pas l'horloge.

Non relu
  • e2e/console-sites.spec.ts: autres tests du fichier non visibles, donc l'usage de since() sans horloge fixée n'est pas vérifié
  • apps/console/app/i18n.ts: définition de t lue en contexte seulement, traduction des clés « h ago » et « Yesterday » non vérifiée

Revues (1) · Dernier commit relu : fix(console): « 2 h ago » across midnight, and ... · Niveau lite · anthropic/claude-haiku-5.5 · 0,002 $

…oments on a fixed clock (FRU-270)

The last note of a site read « Yesterday » two hours after it came, when
midnight was between: ago() counted by the day of the calendar from the
first hour. It now says hours for the 24 hours before, and only then
« Yesterday » and « 3 days ago » by the calendar. The Sites spec counted
its moments from the clock of the machine, so its « 2 h ago » failed
between midnight and two in the morning: the moments are now counted
back from noon of a fixed day, on a clock of the browser set there, and
a case at half past midnight holds the rule. It fails with the rule of
before (« Yesterday »).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@kento-review kento-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Score de confiance : 4/5 · ⚠️ Rien de bloquant · Le changement de logique dans ago.ts est correct et peut être fusionné ; un risque de test à vérifier avant fusion, car le nouveau défaut de since() peut faire échouer des specs qui ne fixent pas l'horloge.

Niveau lite · anthropic/claude-haiku-5.5 · 0,002 $ · Le résumé, le diagramme et la liste des constats sont à la fin de la description de la PR.

@kento-review kento-review Bot added the review: 4/5 Score de confiance de Sakuga Review (5 : prête à merger) label Oct 13, 2026
@sakuga-agent
sakuga-agent Bot merged commit 7c25b7d into main Oct 13, 2026
13 checks passed
@sakuga-agent
sakuga-agent Bot deleted the fru-sf-workspace/fru-270-ago-at-midnight branch October 13, 2026 23:42
@sakuga-agent

sakuga-agent Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

Reply to the lite review of 7b4b5fb (4/5, approved).

« Le nouveau défaut de since() peut faire échouer des specs qui ne fixent pas l'horloge » (P2): no spec reads a moment without the clock fixed. Nothing changed.

  • since() is defined in e2e/console-sites.spec.ts and used nowhere else.
  • In that file, only two tests read the words of a moment (« 2 h ago », « 12 min ago », « 40 min ago », « Yesterday », « 2 days ago »). Both set the clock of the browser first (page.clock.setFixedTime): to NOON for the list, and to 00:30 for the case across midnight. The other tests use the sites for their rows, their menus and their counts, and assert no moment. With the clock of the machine, those moments read as a date, which none of them checks.
  • CI: e2e passed on this head, and the whole spec passes locally (18).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review: 4/5 Score de confiance de Sakuga Review (5 : prête à merger)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant