Repository navigation
feat: Next.js 16 migration with React 19 fixes - #431
Conversation
- Migrate middleware.ts to proxy.ts (Next.js 16 deprecation) - Add --webpack flag to dev/build (Turbopack lacks absolute path alias support for Convex dedup) - Fix SSR-safe Convex client initialization in providers - Fix Maximum update depth exceeded error in chat-messages-panel (React 19 stricter ref handling) - Add suppressHydrationWarning for browser extension compatibility - Add ChatListProvider context for real-time sidebar updates - Improve mobile dashboard nav with streaming indicators 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile OverviewGreptile SummaryThis PR successfully migrates the codebase to Next.js 16 and React 19, addressing several critical build and runtime issues while adding real-time streaming indicators. Key Changes:
Issues Found:
The migration is well-executed with thorough documentation and proper React 19 compatibility fixes. Confidence Score: 4/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant User
participant Client
participant Providers
participant ConvexClient
participant ChatListProvider
participant Sidebar
participant StreamingMutation
Note over Client,Providers: SSR/SSG Phase
Client->>Providers: Initialize (typeof window check)
alt window is undefined (SSR)
Providers->>Client: Render fallback tree (no Convex)
else window exists (Browser)
Providers->>ConvexClient: new ConvexReactClient(url)
Providers->>ChatListProvider: Mount with Convex context
ChatListProvider->>ConvexClient: Subscribe to chats.list
end
Note over User,StreamingMutation: Chat Streaming Flow
User->>Client: Send message
Client->>StreamingMutation: prepareChat()
StreamingMutation->>ConvexClient: PATCH chat (status: "streaming")
ConvexClient-->>ChatListProvider: Real-time update (status: streaming)
ChatListProvider-->>Sidebar: Update status map
Sidebar->>Sidebar: Show streaming indicator dot
Note over Client,StreamingMutation: Stream Completion
StreamingMutation->>ConvexClient: completeStream()
ConvexClient->>ConvexClient: PATCH message (status: completed)
ConvexClient->>ConvexClient: PATCH chat (status: "idle")
ConvexClient-->>ChatListProvider: Real-time update (status: idle)
ChatListProvider-->>Sidebar: Update status map
Sidebar->>Sidebar: Hide streaming indicator
Note over User,Sidebar: Page Reload During Streaming
User->>Client: Reload page
Client->>Providers: Re-initialize
Providers->>ChatListProvider: Re-mount
ChatListProvider->>ConvexClient: Subscribe to chats.list
ConvexClient-->>ChatListProvider: Receive chats (status still "streaming")
ChatListProvider-->>Sidebar: Update with streaming status
Sidebar->>Sidebar: Show streaming indicator (reconnected)
|
| // Chat streaming status: "idle" | "streaming" - used to show spinner in sidebar | ||
| // and enable stream resumption on page reload |
There was a problem hiding this comment.
logic: The status field should use v.union(v.literal("idle"), v.literal("streaming")) instead of v.string() to enforce valid values and prevent typos.
| // Chat streaming status: "idle" | "streaming" - used to show spinner in sidebar | |
| // and enable stream resumption on page reload | |
| // Chat streaming status: "idle" | "streaming" - used to show spinner in sidebar | |
| // and enable stream resumption on page reload | |
| status: v.optional(v.union(v.literal("idle"), v.literal("streaming"))), |
|
|
||
| // Reset chat status to idle when streaming completes | ||
| if (message?.chatId) { | ||
| await ctx.db.patch(message.chatId, { | ||
| status: "idle", | ||
| updatedAt: Date.now(), | ||
| }); |
There was a problem hiding this comment.
logic: If completeStream is called but the message doesn't exist, the chat status won't be reset to "idle". This could leave the sidebar showing a perpetual streaming indicator.
| // Reset chat status to idle when streaming completes | |
| if (message?.chatId) { | |
| await ctx.db.patch(message.chatId, { | |
| status: "idle", | |
| updatedAt: Date.now(), | |
| }); | |
| // Get the message to find the chatId | |
| const message = await ctx.db.get(args.messageId); | |
| if (!message) { | |
| throw new Error("Message not found"); | |
| } | |
| await ctx.db.patch(args.messageId, { | |
| content: args.content, | |
| reasoning: args.reasoning, | |
| thinkingTimeMs: args.thinkingTimeMs, | |
| status: "completed", | |
| }); | |
| // Reset chat status to idle when streaming completes | |
| await ctx.db.patch(message.chatId, { | |
| status: "idle", | |
| updatedAt: Date.now(), | |
| }); |
| type="button" | ||
| onClick={() => handleChatClick(chat.id)} | ||
| onMouseEnter={() => { | ||
| router.prefetch(`/dashboard/chat/${chat.id}`); | ||
| void prefetchChat(chat.id); | ||
| }} | ||
| className={cn( | ||
| "w-full text-left truncate rounded-lg px-3 py-2.5 text-sm transition-colors", | ||
| isActive | ||
| ? "bg-accent text-accent-foreground font-medium" | ||
| : "text-foreground hover:bg-accent/50" | ||
| )} | ||
| > | ||
| {chat.title || "Untitled"} |
There was a problem hiding this comment.
style: Mobile nav doesn't show streaming indicators like the desktop sidebar does. Consider adding the streaming dot here for consistency:
| type="button" | |
| onClick={() => handleChatClick(chat.id)} | |
| onMouseEnter={() => { | |
| router.prefetch(`/dashboard/chat/${chat.id}`); | |
| void prefetchChat(chat.id); | |
| }} | |
| className={cn( | |
| "w-full text-left truncate rounded-lg px-3 py-2.5 text-sm transition-colors", | |
| isActive | |
| ? "bg-accent text-accent-foreground font-medium" | |
| : "text-foreground hover:bg-accent/50" | |
| )} | |
| > | |
| {chat.title || "Untitled"} | |
| <button | |
| type="button" | |
| onClick={() => handleChatClick(chat.id)} | |
| onMouseEnter={() => { | |
| router.prefetch(`/dashboard/chat/${chat.id}`); | |
| void prefetchChat(chat.id); | |
| }} | |
| className={cn( | |
| "w-full flex items-center gap-2 text-left truncate rounded-lg px-3 py-2.5 text-sm transition-colors", | |
| isActive | |
| ? "bg-accent text-accent-foreground font-medium" | |
| : "text-foreground hover:bg-accent/50" | |
| )} | |
| > | |
| {chat.status === "streaming" && <StreamingDot />} | |
| <span className="truncate">{chat.title || "Untitled"}</span> | |
| </button> |
Note: You'd need to import/define StreamingDot component and ensure chat.status is available.
| // REAL-TIME STREAMING STATUS: Use Convex subscription for live status updates | ||
| // This enables the streaming indicator dot in the sidebar | ||
| const { chats: realtimeChats } = useChatList(); | ||
|
|
||
| // Create a map of chat statuses from real-time data for O(1) lookup | ||
| const realtimeStatusMap = useMemo(() => { | ||
| const map = new Map<string, string | undefined>(); | ||
| for (const chat of realtimeChats) { | ||
| map.set(chat._id, chat.status); | ||
| } | ||
| return map; | ||
| }, [realtimeChats]); |
There was a problem hiding this comment.
style: The realtimeChats from useChatList() are fetched separately from initialChats (from server-side rendering). If a chat exists in initialChats but not yet in realtimeChats during initial load, the status map lookup will return undefined. This is fine but could briefly show incorrect status during hydration.
Consider documenting this behavior or ensuring the real-time subscription loads before the component mounts.
| const chatListResult = useQuery( | ||
| api.chats.list, | ||
| userId ? { userId, limit: 200 } : "skip" | ||
| ); |
There was a problem hiding this comment.
style: The limit of 200 chats is hardcoded here but may differ from limits used elsewhere in the app (e.g., mobile nav also uses 200, but if changed in one place, they could get out of sync). Consider extracting to a shared constant.
- Use v.union(v.literal("idle"), v.literal("streaming")) for chat status field instead of v.string() to enforce valid values
- Add error handling in completeStream if message doesn't exist to prevent perpetual streaming indicator
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
Summary
Test plan
bun run build)🤖 Generated with Claude Code