Merge pull request #18 from M3gA-Mind/develop

refactor: streamline message handling in Conversations component
This commit is contained in:
Mega Mind
2026-03-26 23:32:59 +05:30
committed by GitHub
2 changed files with 7 additions and 11 deletions
+5 -6
View File
@@ -21,15 +21,14 @@ import {
import {
chatCancel,
chatSend,
subscribeChatEvents,
useRustChat,
type ChatToolCallEvent,
type ChatToolResultEvent,
subscribeChatEvents,
useRustChat,
} from '../services/chatService';
import { store } from '../store';
import { useAppDispatch, useAppSelector } from '../store/hooks';
import type { NotionPageSummary, NotionSummary, NotionUserProfile } from '../store/notionSlice';
import { store } from '../store';
import { BACKEND_URL } from '../utils/config';
import {
addInferenceResponse,
addMessageLocal,
@@ -46,6 +45,7 @@ import {
setSelectedThread,
} from '../store/threadSlice';
import type { ThreadMessage } from '../types/thread';
import { BACKEND_URL } from '../utils/config';
const MIN_PANEL_WIDTH = 200;
const MAX_PANEL_WIDTH = 480;
@@ -406,7 +406,6 @@ const Conversations = () => {
const handleSendMessageWeb = async (
sendingThreadId: string,
trimmed: string,
userMessage: ThreadMessage,
historySnapshot: ThreadMessage[]
) => {
// Safety-net timeout: force-clear loading states if everything hangs
@@ -729,7 +728,7 @@ const Conversations = () => {
}
} else {
// ── Web fallback (existing orchestration logic) ───────────────────────
await handleSendMessageWeb(sendingThreadId, trimmed, userMessage, historySnapshot);
await handleSendMessageWeb(sendingThreadId, trimmed, historySnapshot);
}
};
+2 -5
View File
@@ -83,7 +83,7 @@ export const sendMessage = createAsyncThunk(
'thread/sendMessage',
async (
{ threadId, message }: { threadId: string; message: string },
{ dispatch, getState, rejectWithValue }
{ dispatch, rejectWithValue }
) => {
// 1. Add user message locally immediately (optimistic update)
const userMessage: ThreadMessage = {
@@ -116,10 +116,7 @@ export const sendMessage = createAsyncThunk(
} catch (error) {
// Add an error message as an agent response so the conversation flow continues
dispatch(
addInferenceResponse({
content: 'Something went wrong — please try again.',
threadId,
})
addInferenceResponse({ content: 'Something went wrong — please try again.', threadId })
);
const msg =