fix: feedback buttons always visible, thread title update for untitled threads
- 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) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
d53655c180
commit
eb200cbdfd
+19
-16
@@ -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,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user