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",
|
"inline-flex items-center text-xs px-1.5 py-0.5 rounded transition-colors",
|
||||||
feedback === "up"
|
feedback === "up"
|
||||||
? "text-green-600 bg-green-100 dark:bg-green-900/30"
|
? "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="有帮助"
|
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",
|
"inline-flex items-center text-xs px-1.5 py-0.5 rounded transition-colors",
|
||||||
feedback === "down"
|
feedback === "down"
|
||||||
? "text-red-600 bg-red-100 dark:bg-red-900/30"
|
? "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="无帮助"
|
title="无帮助"
|
||||||
>
|
>
|
||||||
@@ -588,20 +588,23 @@ function App() {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
if (isFirstMessage && currentThreadId) {
|
// Always set title if thread doesn't have one yet
|
||||||
// Smart title: truncate at word/punctuation boundary instead of mid-word
|
if (currentThreadId && text) {
|
||||||
const rawTitle = text.slice(0, 30);
|
const currentTitle = threads.find((t) => t.thread_id === currentThreadId)?.metadata?.title;
|
||||||
const boundaryMatch = rawTitle.match(/^(.{10,}?)[,。!?、;:\s,.!?;:]/);
|
if (!currentTitle || activeMessages.length === 0) {
|
||||||
const titleText = boundaryMatch ? boundaryMatch[1] : rawTitle.replace(/\s+\S*$/, "") || rawTitle;
|
const rawTitle = text.slice(0, 30);
|
||||||
client.threads.update(currentThreadId, { metadata: { title: titleText } }).catch(() => {});
|
const boundaryMatch = rawTitle.match(/^(.{10,}?)[,。!?、;:\s,.!?;:]/);
|
||||||
try { localStorage.setItem(`title_${currentThreadId}`, titleText); } catch { /* ignore */ }
|
const titleText = boundaryMatch ? boundaryMatch[1] : rawTitle.replace(/\s+\S*$/, "") || rawTitle;
|
||||||
setThreads((prev) =>
|
client.threads.update(currentThreadId, { metadata: { title: titleText } }).catch(() => {});
|
||||||
prev.map((t) =>
|
try { localStorage.setItem(`title_${currentThreadId}`, titleText); } catch { /* ignore */ }
|
||||||
t.thread_id === currentThreadId
|
setThreads((prev) =>
|
||||||
? { ...t, metadata: { ...t.metadata, title: titleText } }
|
prev.map((t) =>
|
||||||
: t,
|
t.thread_id === currentThreadId
|
||||||
),
|
? { ...t, metadata: { ...t.metadata, title: titleText } }
|
||||||
);
|
: t,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user