mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-09-11 22:51:05 +00:00
fix: remove dangling user message when stop is hit before any response
This commit is contained in:
parent
31970edc6b
commit
792c1db861
1 changed files with 12 additions and 1 deletions
|
|
@ -370,6 +370,17 @@ export function ChatSidebar({
|
|||
}
|
||||
}
|
||||
|
||||
// When the user stops generation before any assistant response arrives,
|
||||
// remove the dangling user message so it isn't duplicated on the next send.
|
||||
const handleStop = useCallback(() => {
|
||||
stop()
|
||||
setMessages((prev) => {
|
||||
const last = prev[prev.length - 1]
|
||||
if (last?.role === "user") return prev.slice(0, -1)
|
||||
return prev
|
||||
})
|
||||
}, [stop, setMessages])
|
||||
|
||||
const handleCopyMessage = useCallback((messageId: string, text: string) => {
|
||||
analytics.chatMessageCopied({ message_id: messageId })
|
||||
navigator.clipboard.writeText(text)
|
||||
|
|
@ -1137,7 +1148,7 @@ export function ChatSidebar({
|
|||
value={input}
|
||||
onChange={(e) => setInput(e.target.value)}
|
||||
onSend={handleSend}
|
||||
onStop={stop}
|
||||
onStop={handleStop}
|
||||
onKeyDown={handleKeyDown}
|
||||
isResponding={isResponding}
|
||||
activeStatus={
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue