Skip to content

Commit 0f0e83a

Browse files
authored
Merge pull request awslabs#78 from awslabs/bug/reset-session-id-on-new-chat
Reset UUID in frontend when a new chat is initiated.
2 parents b8a9cfc + 8eb3e2a commit 0f0e83a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

frontend/src/components/chat/ChatInterface.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default function ChatInterface() {
1919
const [input, setInput] = useState("")
2020
const [error, setError] = useState<string | null>(null)
2121
const [client, setClient] = useState<AgentCoreClient | null>(null)
22-
const [sessionId] = useState(() => crypto.randomUUID())
22+
const [sessionId, setSessionId] = useState(() => crypto.randomUUID())
2323

2424
const { isLoading, setIsLoading } = useGlobal()
2525
const auth = useAuth()
@@ -245,13 +245,13 @@ export default function ChatInterface() {
245245
}
246246
}
247247

248-
// Start a new chat (generates new session ID)
248+
// Start a new chat by clearing messages and generating a fresh session ID.
249+
// A new UUID is required so the backend treats this as a distinct conversation context.
249250
const startNewChat = () => {
250251
setMessages([])
251252
setInput("")
252253
setError(null)
253-
// Note: sessionId stays the same for the component lifecycle
254-
// If you want a new session ID, you'd need to remount the component
254+
setSessionId(crypto.randomUUID())
255255
}
256256

257257
// Check if this is the initial state (no messages)

0 commit comments

Comments
 (0)