← Back to Pull requests

fix(desktop): refresh TimeAgo label periodically #1296

Closed
unknown closed this pull request without merging on Nov 22, 2026 08:36 UTC
View on GitHub
unknown unknown commented on Nov 21, 2026 14:05 UTC
Author

Fixes #1289

Problem

The desktop tray shows Last: 5 seconds ago long after the backup finished. In the report, an hourly 15:00 run still showed that text at 15:33.

TimeAgo used useTimeFormat().formatTimeAgo, and that function depends on currentNow. currentNow changes only when the root loader's now changes, which happens on navigation or revalidation. The tray stays mounted and never navigates. Once the last schedule refetch has rendered, nothing renders the label again, so the relative time stays frozen.

Fix

TimeAgo now keeps its own clock. It starts from the loader's now, so hydration still matches. After mount it switches to Date.now() and refreshes every 30 seconds with setInterval, which is cleared on unmount. It then renders rawFormatters.formatTimeAgo(date, now). This also fixes the other TimeAgo users (schedule summary, backup card). useTimeFormat and the shared formatter are unchanged.

Test

Adds app/client/components/__test__/time-ago.test.tsx. It renders TimeAgo under fake timers for a date 5s in the past and expects just now. Then it advances the timers by 30 minutes and expects 30 minutes ago. The test fails on main and passes with this change. The existing datetime tests still pass.

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
<!-- coderabbit-ai-generated:v1 -->

Summary by CodeRabbit

Bug Fixes
Relative-time labels now update automatically every 30 seconds while displayed, keeping elapsed-time descriptions current.
* Time-ago formatting uses a consistent reference time, including during initial page rendering, helping avoid inconsistent labels.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Diff: 219 lines (+164 / -55) across 2 files Reviewer: nicotsx Review duration: 1111m
All Vouch review confidence checks passed
Residual risk 0.14 = Change Risk (0.37) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 219 lines diff across 2 files
0.37
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.323
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #1296"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 36.7% (MEDIUM) · Higher = larger blast radius
36.7%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 14.5% · Safe to merge
14.5%