fix: Consolidate comments

This commit is contained in:
Vanalite 2025-10-01 19:21:34 +07:00
parent 52f73af08c
commit 99473ed568
4 changed files with 1 additions and 8 deletions

View File

@ -17,13 +17,11 @@ export const GenerateResponseButton = ({ threadId }: { threadId: string }) => {
const sendMessage = useChat()
// Detect if last message is a partial assistant response (user stopped midway)
// Only true if message has Stopped status (interrupted by user)
const isPartialResponse = useMemo(() => {
if (!messages || messages.length < 2) return false
const lastMessage = messages[messages.length - 1]
const secondLastMessage = messages[messages.length - 2]
// Partial if: last is assistant with Stopped status, second-last is user, no tool calls
return (
lastMessage?.role === 'assistant' &&
lastMessage?.status === MessageStatus.Stopped &&
@ -33,12 +31,10 @@ export const GenerateResponseButton = ({ threadId }: { threadId: string }) => {
}, [messages])
const generateAIResponse = () => {
// If continuing a partial response, keep the message and continue from it
if (isPartialResponse) {
const partialMessage = messages[messages.length - 1]
const userMessage = messages[messages.length - 2]
if (userMessage?.content?.[0]?.text?.value) {
// Pass the partial message ID to continue from it
sendMessage(
userMessage.content[0].text.value,
false,

View File

@ -29,8 +29,7 @@ const ScrollToBottom = ({
const streamingContent = useAppState((state) => state.streamingContent)
// Check if last message is a partial assistant response (user interrupted)
// Only show button if message has Stopped status (interrupted by user)
// Check if last message is a partial assistant response and show continue buton (user interrupted)
const isPartialResponse =
messages.length >= 2 &&
messages[messages.length - 1]?.role === 'assistant' &&

View File

@ -58,7 +58,6 @@ export const StreamingContent = memo(({ threadId }: Props) => {
}
// Don't show streaming content if there's already a stopped message
// (interrupted message that was just saved)
if (lastAssistant?.status === MessageStatus.Stopped) {
return null
}

View File

@ -452,7 +452,6 @@ export const useChat = () => {
usePrompt.getState().setPrompt('')
const selectedModel = useModelProvider.getState().selectedModel
// Declare accumulatedTextRef BEFORE try block so it's accessible in catch block
// If continuing, start with the previous content
const accumulatedTextRef = {
value: continueFromMessage?.content?.[0]?.text?.value || ''