fix: 欢迎页发送消息后侧边栏即时刷新会话列表
在 handleSend 中 createConversation 成功后立即调用 invalidateQueries, 同时传入 displayModelId 保持与侧边栏新建会话行为一致。
This commit is contained in:
@@ -140,8 +140,9 @@ export function ChatPanel({ conversationId, onConversationCreated, projectId }:
|
|||||||
|
|
||||||
if (!conversationId) {
|
if (!conversationId) {
|
||||||
try {
|
try {
|
||||||
const conv = await createConversation(projectId);
|
const conv = await createConversation(projectId, displayModelId ?? undefined);
|
||||||
skipHistoryLoadRef.current = conv.id;
|
skipHistoryLoadRef.current = conv.id;
|
||||||
|
void queryClient.invalidateQueries({ queryKey: ["conversations", projectId] });
|
||||||
void sendMessage({ text }, { body: { conversationId: conv.id } });
|
void sendMessage({ text }, { body: { conversationId: conv.id } });
|
||||||
onConversationCreated(conv.id);
|
onConversationCreated(conv.id);
|
||||||
} catch (err: unknown) {
|
} catch (err: unknown) {
|
||||||
@@ -153,7 +154,7 @@ export function ChatPanel({ conversationId, onConversationCreated, projectId }:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void sendMessage({ text }, { body: { conversationId } });
|
void sendMessage({ text }, { body: { conversationId } });
|
||||||
}, [input, sendMessage, conversationId, projectId, onConversationCreated, message]);
|
}, [input, sendMessage, conversationId, projectId, onConversationCreated, message, queryClient, displayModelId]);
|
||||||
|
|
||||||
const extractText = useCallback((msg: UIMessage) => {
|
const extractText = useCallback((msg: UIMessage) => {
|
||||||
return msg.parts
|
return msg.parts
|
||||||
|
|||||||
Reference in New Issue
Block a user