Add chat counter back to playground app

This commit is contained in:
akhisud3195 2025-04-10 19:21:00 +05:30
parent 4d4231180f
commit 9994720889

View file

@ -30,6 +30,7 @@ export function App({
mcpServerUrls: Array<z.infer<typeof MCPServer>>; mcpServerUrls: Array<z.infer<typeof MCPServer>>;
toolWebhookUrl: string; toolWebhookUrl: string;
}) { }) {
const [counter, setCounter] = useState<number>(0);
const [testProfile, setTestProfile] = useState<WithStringId<z.infer<typeof TestProfile>> | null>(null); const [testProfile, setTestProfile] = useState<WithStringId<z.infer<typeof TestProfile>> | null>(null);
const [systemMessage, setSystemMessage] = useState<string>(defaultSystemMessage); const [systemMessage, setSystemMessage] = useState<string>(defaultSystemMessage);
const [chat, setChat] = useState<z.infer<typeof PlaygroundChat>>({ const [chat, setChat] = useState<z.infer<typeof PlaygroundChat>>({
@ -45,13 +46,16 @@ export function App({
function handleSystemMessageChange(message: string) { function handleSystemMessageChange(message: string) {
setSystemMessage(message); setSystemMessage(message);
setCounter(counter + 1);
} }
function handleTestProfileChange(profile: WithStringId<z.infer<typeof TestProfile>> | null) { function handleTestProfileChange(profile: WithStringId<z.infer<typeof TestProfile>> | null) {
setTestProfile(profile); setTestProfile(profile);
setCounter(counter + 1);
} }
function handleNewChatButtonClick() { function handleNewChatButtonClick() {
setCounter(counter + 1);
setChat({ setChat({
projectId, projectId,
createdAt: new Date().toISOString(), createdAt: new Date().toISOString(),
@ -139,6 +143,7 @@ export function App({
/> />
<div className="h-full overflow-auto px-4 py-4"> <div className="h-full overflow-auto px-4 py-4">
<Chat <Chat
key={`chat-${counter}`}
chat={chat} chat={chat}
projectId={projectId} projectId={projectId}
workflow={workflow} workflow={workflow}