@marktiderman/genesis-chat 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marktiderman/genesis-chat",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -86,13 +86,13 @@
86
86
  "README.md"
87
87
  ],
88
88
  "dependencies": {
89
- "@marktiderman/genesis-features": "^0.8.0",
89
+ "@marktiderman/genesis-features": "^0.8.1",
90
90
  "frimousse": "0.4.0"
91
91
  },
92
92
  "peerDependencies": {
93
93
  "@marktiderman/genesis-ai": ">=0.1.0 <1.0.0",
94
94
  "@marktiderman/genesis-core": ">=1.17.0 <3.0.0",
95
- "@marktiderman/genesis-ui": ">=2.21.0 <3.0.0",
95
+ "@marktiderman/genesis-ui": ">=2.29.0 <3.0.0",
96
96
  "@marktiderman/genesis-ui-native": ">=2.9.0 <4.0.0",
97
97
  "@supabase/supabase-js": "^2.118.0",
98
98
  "@tanstack/react-query": "^5.0.0",
@@ -173,19 +173,19 @@
173
173
  }
174
174
  },
175
175
  "devDependencies": {
176
- "@ai-sdk/anthropic": "4.0.85",
176
+ "@ai-sdk/anthropic": "4.0.88",
177
177
  "@marktiderman/genesis-ai": "^0.2.0",
178
- "@marktiderman/genesis-core": "^2.4.0",
179
- "@marktiderman/genesis-notifications": "^0.4.0",
180
- "@marktiderman/genesis-ui": "^2.25.1",
181
- "@marktiderman/genesis-ui-native": "^3.2.2",
178
+ "@marktiderman/genesis-core": "^2.8.0",
179
+ "@marktiderman/genesis-notifications": "^0.4.2",
180
+ "@marktiderman/genesis-ui": "^2.29.0",
181
+ "@marktiderman/genesis-ui-native": "^3.5.0",
182
182
  "@supabase/supabase-js": "^2.118.0",
183
183
  "@tanstack/react-query": "^5.104.5",
184
184
  "@testing-library/react": "^16.3.2",
185
185
  "@types/node": "^22",
186
186
  "@types/react": "^19.2.14",
187
187
  "@types/react-dom": "^19.2.3",
188
- "ai": "7.0.148",
188
+ "ai": "7.0.153",
189
189
  "happy-dom": "^21.0.4",
190
190
  "hls.js": "1.7.3",
191
191
  "lucide-react": "^1.28.0",
@@ -0,0 +1,28 @@
1
+ /**
2
+ * The inbox's time is Genesis UI's relativeTime in its compact style, with the words and shapes
3
+ * the inbox always had: "now", "5m", the clock time today, "Yesterday", the weekday, the date.
4
+ */
5
+ import { describe, expect, it } from "vitest";
6
+ import { relativeTime } from "../web/format";
7
+
8
+ const local = (y: number, mo: number, d: number, h = 0, mi = 0) => new Date(y, mo - 1, d, h, mi);
9
+ const NOW = local(2026, 6, 17, 15, 0); // a Wednesday
10
+
11
+ describe("relativeTime (inbox)", () => {
12
+ it("says nothing for no time, now under a minute, and minutes under an hour", () => {
13
+ expect(relativeTime(null, NOW)).toBe("");
14
+ expect(relativeTime(local(2026, 6, 17, 14, 59, ).toISOString(), NOW, "en-US")).toBe("1m");
15
+ expect(relativeTime(new Date(NOW.getTime() - 20_000).toISOString(), NOW, "en-US")).toBe("now");
16
+ expect(relativeTime(local(2026, 6, 17, 14, 5).toISOString(), NOW, "en-US")).toBe("55m");
17
+ });
18
+
19
+ it("says the clock time today, Yesterday, the weekday this week and the date after", () => {
20
+ expect(relativeTime(local(2026, 6, 17, 9, 30).toISOString(), NOW, "en-US")).toBe(
21
+ local(2026, 6, 17, 9, 30).toLocaleTimeString("en-US", { hour: "numeric", minute: "2-digit" }),
22
+ );
23
+ expect(relativeTime(local(2026, 6, 16, 9, 30).toISOString(), NOW, "en-US")).toBe("Yesterday");
24
+ expect(relativeTime(local(2026, 6, 14, 9, 30).toISOString(), NOW, "en-US")).toBe("Sun");
25
+ expect(relativeTime(local(2026, 3, 12, 9, 30).toISOString(), NOW, "en-GB")).toBe("12 Mar");
26
+ expect(relativeTime(local(2025, 3, 12, 9, 30).toISOString(), NOW, "en-GB")).toBe("12 Mar 2025");
27
+ });
28
+ });
package/src/web/format.ts CHANGED
@@ -3,6 +3,7 @@
3
3
  * Small formatting helpers for the web renderers: times, sizes, and the
4
4
  * one-line description of a message a screen reader hears.
5
5
  */
6
+ import { relativeTime as uiRelativeTime } from "@marktiderman/genesis-ui/utils";
6
7
  import { previewText } from "../core/thread";
7
8
  import type { ChatMessage } from "../core/types";
8
9
 
@@ -19,23 +20,13 @@ export function clockTime(iso: string, locale?: string): string {
19
20
  return new Date(iso).toLocaleTimeString(locale, { hour: "numeric", minute: "2-digit" });
20
21
  }
21
22
 
22
- /** The inbox's time: "now", "5m", "10:42" today, "Yesterday", "Mon", or "12 Mar". */
23
+ /**
24
+ * The inbox's time: "now", "5m", "10:42" today, "Yesterday", "Mon", or "12 Mar". Genesis UI's
25
+ * `relativeTime` in its compact style, in the reader's locale (`locale`, default the runtime's).
26
+ */
23
27
  export function relativeTime(iso: string | null | undefined, now = new Date(), locale?: string): string {
24
28
  if (!iso) return "";
25
- const d = new Date(iso);
26
- const diff = now.getTime() - d.getTime();
27
- if (diff < 60_000) return "now";
28
- if (diff < 3_600_000) return `${Math.floor(diff / 60_000)}m`;
29
- const startOf = (x: Date) => new Date(x.getFullYear(), x.getMonth(), x.getDate()).getTime();
30
- const days = Math.round((startOf(now) - startOf(d)) / 86_400_000);
31
- if (days === 0) return clockTime(iso, locale);
32
- if (days === 1) return "Yesterday";
33
- if (days > 1 && days < 7) return d.toLocaleDateString(locale, { weekday: "short" });
34
- return d.toLocaleDateString(locale, {
35
- day: "numeric",
36
- month: "short",
37
- year: d.getFullYear() === now.getFullYear() ? undefined : "numeric",
38
- });
29
+ return uiRelativeTime(iso, now, { style: "compact", locale: locale ?? new Intl.DateTimeFormat().resolvedOptions().locale });
39
30
  }
40
31
 
41
32
  /** 12 KB, 3.4 MB. */
@@ -718,7 +718,7 @@ export function ChatThread({
718
718
 
719
719
  {search && !threadRootId ? (
720
720
  <Sheet open={searching} onOpenChange={setSearching}>
721
- <SheetContent side="right" className="flex w-full flex-col gap-0 p-0 sm:max-w-md">
721
+ <SheetContent side="right" className="flex w-full flex-col gap-0 p-0 pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)] sm:max-w-md">
722
722
  <SheetHeader className="border-b px-4 py-3">
723
723
  <SheetTitle>Search</SheetTitle>
724
724
  <SheetDescription className="sr-only">Search this conversation and jump to a message.</SheetDescription>