fix(15): pass sessionId to fetchChatHistory for session messages

The fetchChatHistory thunk needs sessionId to determine channel type:
- With sessionId: fetches 'session' channel messages
- Without sessionId: fetches 'global' channel messages

The useEffect was only passing `channel` (which is the sessionId for
session chats), but not the `sessionId` parameter. This caused the
API to fetch global chat instead of session chat, so session messages
disappeared after page reload.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Nuwan 2026-02-06 16:04:41 +05:30
parent da4e864ab7
commit 5df60ad6cf
1 changed files with 7 additions and 2 deletions

View File

@ -131,9 +131,14 @@ const JKChatMessageList = () => {
*/
useEffect(() => {
if (activeChannel && fetchStatus !== 'loading' && fetchStatus !== 'succeeded') {
dispatch(fetchChatHistory({ channel: activeChannel }));
// For session chat, activeChannel is the sessionId
// Pass sessionId so the thunk knows to fetch 'session' channel type
dispatch(fetchChatHistory({
channel: activeChannel,
sessionId: sessionId || activeChannel // Use sessionId from Redux, fallback to activeChannel
}));
}
}, [dispatch, activeChannel, fetchStatus]);
}, [dispatch, activeChannel, sessionId, fetchStatus]);
// Loading state
if (fetchStatus === 'loading' && messages.length === 0) {