From eb200cbdfd3275821ee85134f8654c129aa152b0 Mon Sep 17 00:00:00 2001 From: gongzhiyong Date: Tue, 14 Apr 2026 01:29:27 +0800 Subject: [PATCH] fix: feedback buttons always visible, thread title update for untitled threads MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove opacity-0 group-hover from ThumbsUp/ThumbsDown buttons — always visible - Fix thread title: update title whenever currentTitle is empty, not just first message Co-Authored-By: Claude Opus 4.6 (1M context) --- langgraph/src/main.tsx | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/langgraph/src/main.tsx b/langgraph/src/main.tsx index ccecd14..9ff5605 100644 --- a/langgraph/src/main.tsx +++ b/langgraph/src/main.tsx @@ -153,7 +153,7 @@ function FeedbackButtons({ messageId }: { messageId: string }) { "inline-flex items-center text-xs px-1.5 py-0.5 rounded transition-colors", feedback === "up" ? "text-green-600 bg-green-100 dark:bg-green-900/30" - : "opacity-0 group-hover:opacity-100 text-muted-foreground hover:text-foreground hover:bg-accent", + : "text-muted-foreground hover:text-foreground hover:bg-accent", )} title="有帮助" > @@ -166,7 +166,7 @@ function FeedbackButtons({ messageId }: { messageId: string }) { "inline-flex items-center text-xs px-1.5 py-0.5 rounded transition-colors", feedback === "down" ? "text-red-600 bg-red-100 dark:bg-red-900/30" - : "opacity-0 group-hover:opacity-100 text-muted-foreground hover:text-foreground hover:bg-accent", + : "text-muted-foreground hover:text-foreground hover:bg-accent", )} title="无帮助" > @@ -588,20 +588,23 @@ function App() { }, ); - if (isFirstMessage && currentThreadId) { - // Smart title: truncate at word/punctuation boundary instead of mid-word - const rawTitle = text.slice(0, 30); - const boundaryMatch = rawTitle.match(/^(.{10,}?)[,。!?、;:\s,.!?;:]/); - const titleText = boundaryMatch ? boundaryMatch[1] : rawTitle.replace(/\s+\S*$/, "") || rawTitle; - client.threads.update(currentThreadId, { metadata: { title: titleText } }).catch(() => {}); - try { localStorage.setItem(`title_${currentThreadId}`, titleText); } catch { /* ignore */ } - setThreads((prev) => - prev.map((t) => - t.thread_id === currentThreadId - ? { ...t, metadata: { ...t.metadata, title: titleText } } - : t, - ), - ); + // Always set title if thread doesn't have one yet + if (currentThreadId && text) { + const currentTitle = threads.find((t) => t.thread_id === currentThreadId)?.metadata?.title; + if (!currentTitle || activeMessages.length === 0) { + const rawTitle = text.slice(0, 30); + const boundaryMatch = rawTitle.match(/^(.{10,}?)[,。!?、;:\s,.!?;:]/); + const titleText = boundaryMatch ? boundaryMatch[1] : rawTitle.replace(/\s+\S*$/, "") || rawTitle; + client.threads.update(currentThreadId, { metadata: { title: titleText } }).catch(() => {}); + try { localStorage.setItem(`title_${currentThreadId}`, titleText); } catch { /* ignore */ } + setThreads((prev) => + prev.map((t) => + t.thread_id === currentThreadId + ? { ...t, metadata: { ...t.metadata, title: titleText } } + : t, + ), + ); + } } }