From e462314100f242e6c24b67d54db63f4aca839bcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=91=98=E9=98=BF=E6=B1=9F=28Relakkes?= =?UTF-8?q?=29?= Date: Thu, 9 Apr 2026 00:34:58 +0800 Subject: [PATCH] feat: MessageList and ChatInput read from per-session state Both components now look up state via activeTabId from useTabStore, reading from sessions[activeTabId] in chatStore. Action calls (sendMessage, stopGeneration) pass the sessionId as first argument. Co-Authored-By: Claude Sonnet 4.6 --- desktop/src/components/chat/ChatInput.tsx | 11 ++++++++--- desktop/src/components/chat/MessageList.tsx | 8 +++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/desktop/src/components/chat/ChatInput.tsx b/desktop/src/components/chat/ChatInput.tsx index 9da3a06f..e89447c7 100644 --- a/desktop/src/components/chat/ChatInput.tsx +++ b/desktop/src/components/chat/ChatInput.tsx @@ -1,6 +1,7 @@ import { useState, useRef, useEffect, useCallback, useMemo } from 'react' import { useTranslation } from '../../i18n' import { useChatStore } from '../../stores/chatStore' +import { useTabStore } from '../../stores/tabStore' import { useSessionStore } from '../../stores/sessionStore' import { sessionsApi } from '../../api/sessions' import { PermissionModeSelector } from '../controls/PermissionModeSelector' @@ -43,7 +44,11 @@ export function ChatInput() { const slashMenuRef = useRef(null) const fileSearchRef = useRef(null) const slashItemRefs = useRef<(HTMLButtonElement | null)[]>([]) - const { sendMessage, chatState, stopGeneration, slashCommands } = useChatStore() + const { sendMessage, stopGeneration } = useChatStore() + const activeTabId = useTabStore((s) => s.activeTabId) + const sessionState = useChatStore((s) => activeTabId ? s.sessions[activeTabId] : undefined) + const chatState = sessionState?.chatState ?? 'idle' + const slashCommands = sessionState?.slashCommands ?? [] const activeSessionId = useSessionStore((state) => state.activeSessionId) const activeSession = useSessionStore((state) => state.sessions.find((session) => session.id === state.activeSessionId) ?? null) const [gitInfo, setGitInfo] = useState(null) @@ -213,7 +218,7 @@ export function ChatInput() { mimeType: attachment.mimeType, })) - sendMessage(text, attachmentPayload) + sendMessage(activeTabId!, text, attachmentPayload) setInput('') setAttachments([]) setSlashMenuOpen(false) @@ -494,7 +499,7 @@ export function ChatInput() {