fix(frontend): Prevent duplicate tool response UI elements

- Replace all local messages with just completed assistant message on stream_end
- This prevents tool responses from showing twice when initialMessages updates
- Remove unused withFeatureFlag import from chat page
This commit is contained in:
Swifty
2025-10-30 17:08:38 +01:00
parent 922135239d
commit 1351ca02b4
2 changed files with 8 additions and 3 deletions

View File

@@ -414,7 +414,13 @@ export function useChatContainer({
content: completedContent,
timestamp: new Date(),
};
setMessages((prev) => [...prev, assistantMessage]);
// Replace ALL local messages with just the completed message
// This prevents duplicates when initialMessages updates from backend
setMessages([assistantMessage]);
} else {
// No text content, just clear all local messages
setMessages([]);
}
// Clear streaming state immediately now that we have the message

View File

@@ -4,7 +4,6 @@ import { useChatPage } from "./useChatPage";
import { ChatContainer } from "./components/ChatContainer/ChatContainer";
import { ChatErrorState } from "./components/ChatErrorState/ChatErrorState";
import { ChatLoadingState } from "./components/ChatLoadingState/ChatLoadingState";
import { withFeatureFlag } from "@/services/feature-flags/with-feature-flag";
function ChatPage() {
const {
@@ -69,4 +68,4 @@ function ChatPage() {
);
}
export default withFeatureFlag(ChatPage, "chat");
export default ChatPage;