Skip to content

Commit 15973af

Browse files
mchestrclaude
andcommitted
fix: resolve ChatMessage type export issue in server actions
Removed type re-export from server action file which was causing Next.js to incorrectly bundle types into the runtime server actions bundle. Updated all imports to reference types directly from the types file. This fixes the "ReferenceError: ChatMessage is not defined" error that was occurring during E2E tests when the server tried to load the actions module. Changes: - Removed `export type { ChatMessage, ChatResponse }` from actions/chatbot/index.ts - Updated imports in components and tests to use @/actions/chatbot/types - All type imports now correctly use the type modifier 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent cfdf638 commit 15973af

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

__tests__/actions/chatbot.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
* Tests for actions/chatbot.ts - chatbot sources tracking functionality
33
*/
44

5-
import { chatWithAdminBot, type ChatMessage } from "@/actions/chatbot"
5+
import { chatWithAdminBot } from "@/actions/chatbot"
6+
import { type ChatMessage } from "@/actions/chatbot/types"
67
import { callChatLLM } from "@/lib/llm/chat"
78
import { prisma } from "@/lib/prisma"
89
import { getServerSession } from "next-auth"

actions/chatbot/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import { type ChatMessage, type ChatResponse } from "./types"
99

1010
const logger = createLogger("CHATBOT")
1111

12-
export type { ChatMessage, ChatResponse }
13-
1412
export async function chatWithAdminBot(
1513
messages: ChatMessage[],
1614
conversationId?: string

components/__tests__/admin/chatbot/chat-window.test.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import { Chatbot } from "@/components/admin/chatbot/chat-window"
66
import { ChatProvider } from "@/components/admin/chatbot/chat-context"
77
import { render, screen, waitFor } from "@testing-library/react"
88
import userEvent from "@testing-library/user-event"
9-
import { chatWithAdminBot, type ChatMessage } from "@/actions/chatbot"
9+
import { chatWithAdminBot } from "@/actions/chatbot"
10+
import { type ChatMessage } from "@/actions/chatbot/types"
1011

1112
// Mock the chatbot action
1213
jest.mock("@/actions/chatbot", () => ({

components/admin/chatbot/chat-window.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use client"
22

3-
import { chatWithAdminBot, type ChatMessage } from "@/actions/chatbot"
3+
import { chatWithAdminBot } from "@/actions/chatbot"
4+
import { type ChatMessage } from "@/actions/chatbot/types"
45
import { AnimatePresence, motion } from "framer-motion"
56
import dynamic from "next/dynamic"
67
import { useEffect, useRef, useState } from "react"

0 commit comments

Comments
 (0)