story-kit: merge 215_bug_cancel_button_still_discards_queued_messages_197_regression
This commit is contained in:
@@ -8,6 +8,7 @@ import { useChatHistory } from "../hooks/useChatHistory";
|
||||
import type { Message, ProviderConfig } from "../types";
|
||||
import { AgentPanel } from "./AgentPanel";
|
||||
import { ChatHeader } from "./ChatHeader";
|
||||
import type { ChatInputHandle } from "./ChatInput";
|
||||
import { ChatInput } from "./ChatInput";
|
||||
import { LozengeFlyProvider } from "./LozengeFlyContext";
|
||||
import { MessageItem } from "./MessageItem";
|
||||
@@ -200,6 +201,7 @@ export function Chat({ projectPath, onCloseProject }: ChatProps) {
|
||||
>(null);
|
||||
|
||||
const wsRef = useRef<ChatWebSocket | null>(null);
|
||||
const chatInputRef = useRef<ChatInputHandle>(null);
|
||||
const messagesEndRef = useRef<HTMLDivElement>(null);
|
||||
const scrollContainerRef = useRef<HTMLDivElement>(null);
|
||||
const shouldAutoScrollRef = useRef(true);
|
||||
@@ -419,7 +421,13 @@ export function Chat({ projectPath, onCloseProject }: ChatProps) {
|
||||
}, []);
|
||||
|
||||
const cancelGeneration = async () => {
|
||||
// Discard any queued messages — do not auto-send after cancel
|
||||
// Preserve queued messages by appending them to the chat input box
|
||||
if (queuedMessagesRef.current.length > 0) {
|
||||
const queued = queuedMessagesRef.current
|
||||
.map((item) => item.text)
|
||||
.join("\n");
|
||||
chatInputRef.current?.appendToInput(queued);
|
||||
}
|
||||
queuedMessagesRef.current = [];
|
||||
setQueuedMessages([]);
|
||||
try {
|
||||
@@ -843,6 +851,7 @@ export function Chat({ projectPath, onCloseProject }: ChatProps) {
|
||||
|
||||
{/* Chat input pinned at bottom of left column */}
|
||||
<ChatInput
|
||||
ref={chatInputRef}
|
||||
loading={loading}
|
||||
queuedMessages={queuedMessages}
|
||||
onSubmit={sendMessage}
|
||||
|
||||
Reference in New Issue
Block a user