Make commit history easier to scan and review (#2146)

* feat(app): improve commit history and diff review

* fix(app): keep commit timestamps current

* fix(app): pause hidden commit clocks

* fix(app): reopen commit diff in persistence test
This commit is contained in:
Mohamed Boudra
2026-07-17 04:15:04 +08:00
committed by GitHub
parent 60855a0f3a
commit 737f30c339
6 changed files with 210 additions and 22 deletions
+16 -1
View File
@@ -1,5 +1,20 @@
import { describe, it, expect } from "vitest";
import { formatDuration, formatMessageTimestamp } from "./time";
import { formatDuration, formatMessageTimestamp, formatTimeAgo } from "./time";
describe("formatTimeAgo", () => {
const now = new Date("2026-07-16T12:00:00.000Z");
it.each([
["2026-07-16T11:59:55.000Z", "just now"],
["2026-07-16T11:59:30.000Z", "30s ago"],
["2026-07-16T11:55:00.000Z", "5m ago"],
["2026-07-16T10:00:00.000Z", "2h ago"],
["2026-07-13T12:00:00.000Z", "3d ago"],
["2026-01-15T12:00:00.000Z", "Jan 15"],
])("formats %s as %s", (date, expected) => {
expect(formatTimeAgo(new Date(date), now)).toBe(expected);
});
});
describe("formatDuration", () => {
it("renders sub-minute durations as whole seconds", () => {
+1 -2
View File
@@ -2,8 +2,7 @@
* Format a date as a human-friendly relative time string
* Examples: "just now", "5m ago", "2h ago", "3d ago", "Jan 15"
*/
export function formatTimeAgo(date: Date): string {
const now = new Date();
export function formatTimeAgo(date: Date, now: Date = new Date()): string {
const diffMs = now.getTime() - date.getTime();
const diffSec = Math.floor(diffMs / 1000);
const diffMin = Math.floor(diffSec / 60);