@firstlovecenter/ai-chat 0.8.0 → 0.8.1

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/CHANGELOG.md CHANGED
@@ -5,6 +5,31 @@ All notable changes to `@firstlovecenter/ai-chat` are documented here.
5
5
  The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and the project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.8.1] — 2026-05-09
9
+
10
+ UX polish on top of 0.8.0's URL-driven session restore.
11
+
12
+ ### Changed
13
+
14
+ - **Sidebar entries are now `<Link href="/chat/${id}">`** instead of buttons that call `router.push` from a fetch-then-navigate effect. Cleaner navigation (Next prefetches the destination on hover, full-page semantics work as expected) and removes a race where the click would feel unresponsive while the in-flight fetch from the previous handler tore down with the unmounting component.
15
+ - **`+ New chat` navigates to `/chat?new`** — the host's `/chat` route is expected to redirect to the most-recent session by default and treat `?new` as a hint to skip the redirect. Without this, hosts that wire a redirect would bounce the user back into the session they were trying to leave.
16
+
17
+ ### Migration notes
18
+
19
+ Hosts that wire a "land on /chat → resume most-recent session" redirect should respect `searchParams.new`:
20
+
21
+ ```ts
22
+ if (searchParams.new === undefined) {
23
+ const [recent] = await db
24
+ .select({ id: chatSessions.id })
25
+ .from(chatSessions)
26
+ .where(eq(chatSessions.userId, ctx.userId))
27
+ .orderBy(desc(chatSessions.updatedAt))
28
+ .limit(1);
29
+ if (recent) redirect(`/chat/${recent.id}`);
30
+ }
31
+ ```
32
+
8
33
  ## [0.8.0] — 2026-05-09
9
34
 
10
35
  Conversation memory in the agent loop, plus URL-driven session restore. Follow-up questions in the same chat (`"summarize that"`, `"how many of those are youth?"`) now resolve correctly because each request seeds the LLM context with prior turns. The chat UI is now URL-addressable (`/chat/[id]`), so reload, multi-tab, and bookmarks restore the exact conversation the user was viewing.
package/dist/ui/index.cjs CHANGED
@@ -3,12 +3,15 @@
3
3
 
4
4
  var React = require('react');
5
5
  var navigation = require('next/navigation');
6
+ var Link = require('next/link');
6
7
  var lucideReact = require('lucide-react');
7
8
  var radixUi = require('radix-ui');
8
9
  var jsxRuntime = require('react/jsx-runtime');
9
10
  var RechartsPrimitive = require('recharts');
10
11
  var react = require('@ai-sdk/react');
11
12
 
13
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
14
+
12
15
  function _interopNamespace(e) {
13
16
  if (e && e.__esModule) return e;
14
17
  var n = Object.create(null);
@@ -28,6 +31,7 @@ function _interopNamespace(e) {
28
31
  }
29
32
 
30
33
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
34
+ var Link__default = /*#__PURE__*/_interopDefault(Link);
31
35
  var RechartsPrimitive__namespace = /*#__PURE__*/_interopNamespace(RechartsPrimitive);
32
36
 
33
37
  // src/ui/_shared/cn.ts
@@ -772,8 +776,8 @@ function AiChat({
772
776
  setActiveSessionId(null);
773
777
  setAnswers([]);
774
778
  setQuestion("");
775
- syncUrl(null);
776
- }, [syncUrl]);
779
+ router.push("/chat?new");
780
+ }, [router]);
777
781
  const changeProvider = React.useCallback(
778
782
  async (next) => {
779
783
  if (next === provider || providerSaving) return;
@@ -796,7 +800,7 @@ function AiChat({
796
800
  },
797
801
  [provider, providerSaving]
798
802
  );
799
- const openSession = React.useCallback(
803
+ React.useCallback(
800
804
  async (id) => {
801
805
  setLoadingSession(true);
802
806
  setActiveSessionId(id);
@@ -1024,13 +1028,10 @@ function AiChat({
1024
1028
  }
1025
1029
  return /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "group relative", children: [
1026
1030
  /* @__PURE__ */ jsxRuntime.jsx(
1027
- "button",
1031
+ Link__default.default,
1028
1032
  {
1029
- type: "button",
1030
- onClick: () => {
1031
- void openSession(s.id);
1032
- setSidebarOpen(false);
1033
- },
1033
+ href: `/chat/${s.id}`,
1034
+ onClick: () => setSidebarOpen(false),
1034
1035
  className: cn(
1035
1036
  "flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm",
1036
1037
  active ? "bg-sidebar-accent text-sidebar-accent-foreground" : "text-sidebar-foreground/80 hover:bg-sidebar-accent/60 hover:text-sidebar-foreground"
@@ -1755,8 +1756,8 @@ function VercelChat({
1755
1756
  setHydratedErrors({});
1756
1757
  setStartedAt({});
1757
1758
  setInput("");
1758
- syncUrl(null);
1759
- }, [setMessages, setInput, syncUrl]);
1759
+ router.push("/chat?new");
1760
+ }, [setMessages, setInput, router]);
1760
1761
  const changeProvider = React.useCallback(
1761
1762
  async (next) => {
1762
1763
  if (next === provider || providerSaving) return;
@@ -1779,7 +1780,7 @@ function VercelChat({
1779
1780
  },
1780
1781
  [provider, providerSaving]
1781
1782
  );
1782
- const openSession = React.useCallback(
1783
+ React.useCallback(
1783
1784
  async (id) => {
1784
1785
  setLoadingSession(true);
1785
1786
  setActiveSessionId(id);
@@ -1984,13 +1985,10 @@ function VercelChat({
1984
1985
  }
1985
1986
  return /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "group relative", children: [
1986
1987
  /* @__PURE__ */ jsxRuntime.jsx(
1987
- "button",
1988
+ Link__default.default,
1988
1989
  {
1989
- type: "button",
1990
- onClick: () => {
1991
- void openSession(s.id);
1992
- setSidebarOpen(false);
1993
- },
1990
+ href: `/chat/${s.id}`,
1991
+ onClick: () => setSidebarOpen(false),
1994
1992
  className: cn(
1995
1993
  "flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm",
1996
1994
  active ? "bg-sidebar-accent text-sidebar-accent-foreground" : "text-sidebar-foreground/80 hover:bg-sidebar-accent/60 hover:text-sidebar-foreground"