feat: newest message first, Raycast-style conversation sidebar (#7)

This commit was merged in pull request #7.
This commit is contained in:
2026-10-03 21:15:44 +00:00
parent 9b35fcef11
commit ffe2c6b7ed
9 changed files with 300 additions and 187 deletions
+36 -1
View File
@@ -1,5 +1,11 @@
import { describe, expect, it } from "vitest";
import { errorMessage, formatRelativeTime, titleFromPrompt, truncate } from "../lib/utils";
import {
errorMessage,
formatRelativeTime,
recencyGroup,
titleFromPrompt,
truncate,
} from "../lib/utils";
describe("truncate", () => {
it("collapses whitespace so list rows never wrap unexpectedly", () => {
@@ -38,6 +44,35 @@ describe("formatRelativeTime", () => {
});
});
describe("recencyGroup", () => {
// Fixed local noon so the day boundaries are unambiguous on any machine.
const now = new Date(2026, 9, 4, 12, 0, 0).getTime();
const DAY = 86_400_000;
it("buckets today", () => {
expect(recencyGroup(now - 60_000, now)).toBe("Today");
});
it("buckets yesterday", () => {
expect(recencyGroup(new Date(2026, 9, 3, 12, 0, 0).getTime(), now)).toBe("Yesterday");
});
it("buckets the rest of the week", () => {
expect(recencyGroup(now - 3 * DAY, now)).toBe("This week");
expect(recencyGroup(now - 6 * DAY, now)).toBe("This week");
});
it("buckets anything older", () => {
expect(recencyGroup(now - 30 * DAY, now)).toBe("Older");
});
it("does not bucket the small hours of today as yesterday", () => {
// Just after midnight is still today, even though it is under 24h ago.
const justAfterMidnight = new Date(2026, 9, 4, 0, 5, 0).getTime();
expect(recencyGroup(justAfterMidnight, now)).toBe("Today");
});
});
describe("titleFromPrompt", () => {
it("uses the first non-empty line, stripped of markdown decoration", () => {
expect(titleFromPrompt("\n\n## How do I deploy?\nmore text", 60)).toBe("How do I deploy?");