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
+21
View File
@@ -29,6 +29,27 @@ export function formatRelativeTime(timestamp: number, now: number = Date.now()):
return new Date(timestamp).toLocaleDateString(undefined, { month: "short", day: "numeric" });
}
export type RecencyGroup = "Today" | "Yesterday" | "This week" | "Older";
/**
* Buckets a timestamp for the conversation sidebar.
*
* Raycast groups its sidebar this way, and it buys the grouping that per-row
* timestamps were trying to convey — without putting a timestamp on every row.
*/
export function recencyGroup(timestamp: number, now: number = Date.now()): RecencyGroup {
const startOfToday = new Date(now);
startOfToday.setHours(0, 0, 0, 0);
const start = startOfToday.getTime();
const DAY = 86_400_000;
if (timestamp >= start) return "Today";
if (timestamp >= start - DAY) return "Yesterday";
if (timestamp >= start - 7 * DAY) return "This week";
return "Older";
}
/** Pulls a human-readable message out of anything that can be thrown. */
export function errorMessage(error: unknown): string {
if (error instanceof Error) return error.message;