From 5f09079696f9dc4d0d55571ecc38997b3199cd33 Mon Sep 17 00:00:00 2001 From: xintaofei Date: Sun, 15 Mar 2026 11:50:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BC=9A=E8=AF=9Dfork?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/chat/message-input.tsx | 1 + .../conversation-detail-panel.tsx | 26 ++++++++++--------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/components/chat/message-input.tsx b/src/components/chat/message-input.tsx index d954cc4..a2104a5 100644 --- a/src/components/chat/message-input.tsx +++ b/src/components/chat/message-input.tsx @@ -1333,6 +1333,7 @@ export function MessageInput({ disabled={disabled || !hasSendableContent} size="icon" className="rounded-l-none border-l border-primary-foreground/20 w-6" + aria-label={t("forkAndSend")} > diff --git a/src/components/conversations/conversation-detail-panel.tsx b/src/components/conversations/conversation-detail-panel.tsx index f8d71e4..c5ab94e 100644 --- a/src/components/conversations/conversation-detail-panel.tsx +++ b/src/components/conversations/conversation-detail-panel.tsx @@ -611,6 +611,13 @@ const ConversationTabView = memo(function ConversationTabView({ handleSendRef.current = handleSend }, [handleSend]) + // Resolve the current conversation title from tab context (most up-to-date) + // or fall back to the DB detail summary. + const conversationTitle = useMemo(() => { + const tabTitle = tabs.find((tab) => tab.id === tabId)?.title + return tabTitle || detail?.summary.title || null + }, [tabs, tabId, detail?.summary.title]) + const handleForkSend = useCallback( async (draft: PromptDraft, selectedModeIdArg?: string | null) => { const connectionId = conn.connectionId @@ -621,20 +628,17 @@ const ConversationTabView = memo(function ConversationTabView({ ) const persistedId = dbConvIdRef.current if (persistedId != null) { - const currentTab = tabs.find((tab) => tab.id === tabId) - const currentTitle = - currentTab?.title || detail?.summary.title || t("newConversation") + const baseTitle = conversationTitle ?? t("newConversation") + // Strip existing [Fork] prefix to avoid stacking + const cleanTitle = baseTitle.replace(/^\[Fork]\s*/g, "") // Point current conversation at S2 (forked) and add fork tag await updateConversationExternalId(persistedId, forkedSessionId) - await updateConversationTitle( - persistedId, - `[Fork] ${currentTitle}` - ) + await updateConversationTitle(persistedId, `[Fork] ${cleanTitle}`) // Save original S1 as a separate conversation with original title const s1ConvId = await createConversation( folderId, selectedAgent, - currentTitle + cleanTitle ) await updateConversationExternalId(s1ConvId, originalSessionId) await updateConversationStatus(s1ConvId, "pending_review") @@ -644,7 +648,7 @@ const ConversationTabView = memo(function ConversationTabView({ setExternalId(effectiveConversationId, forkedSessionId) await refreshConversations() - // Now send the message on the forked session (S2) + // Send the message on the forked session (S2) handleSend(draft, selectedModeIdArg) } catch (err) { toast.error( @@ -662,7 +666,7 @@ const ConversationTabView = memo(function ConversationTabView({ [ conn.connectionId, connStatus, - detail?.summary.title, + conversationTitle, effectiveConversationId, folderId, handleSend, @@ -670,8 +674,6 @@ const ConversationTabView = memo(function ConversationTabView({ selectedAgent, setExternalId, t, - tabId, - tabs, ] )