Unverified 提交 28811055 authored 作者: Nour Zakhma's avatar Nour Zakhma 提交者: GitHub

Display version in ChatMessage UI (#3191)

closes #2416 This PR addresses the following improvements and fixes in the chat message UI for assistant messages: Commit Hash Display: The commit hash is now shown as a sibling to the commit message in the metadata row, following the commit message and icon. Minimal Tooltip: The tooltip for the commit hash now displays only the commit hash itself (no commit message or extra text), providing a clean and focused UX. Copy-to-Clipboard: Users can copy the full commit hash by clicking the hash or copy icon <img width="769" height="199" alt="image" src="https://github.com/user-attachments/assets/9b28db64-6521-4ee7-b46c-a3b9e8ee9389" /> <!-- devin-review-badge-begin --> --- <a href="https://app.devin.ai/review/dyad-sh/dyad/pull/3191" target="_blank"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1"> <img src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1" alt="Open with Devin"> </picture> </a> <!-- devin-review-badge-end -->
上级 b6c61820
...@@ -123,6 +123,14 @@ const ChatMessage = ({ ...@@ -123,6 +123,14 @@ const ChatMessage = ({
return null; return null;
}, [message.commitHash, message.role, liveVersions]); }, [message.commitHash, message.role, liveVersions]);
// Calculate version number (sequential: oldest = 1, newest = liveVersions.length)
const versionNumber = useMemo(() => {
if (messageVersion && liveVersions.length) {
return liveVersions.length - liveVersions.indexOf(messageVersion);
}
return null;
}, [messageVersion, liveVersions]);
// handle copy request id // handle copy request id
const [copiedRequestId, setCopiedRequestId] = useState(false); const [copiedRequestId, setCopiedRequestId] = useState(false);
const copiedRequestIdTimeoutRef = useRef<NodeJS.Timeout | null>(null); const copiedRequestIdTimeoutRef = useRef<NodeJS.Timeout | null>(null);
...@@ -283,12 +291,12 @@ const ChatMessage = ({ ...@@ -283,12 +291,12 @@ const ChatMessage = ({
<Clock className="h-3 w-3" /> <Clock className="h-3 w-3" />
<span>{formatTimestamp(message.createdAt)}</span> <span>{formatTimestamp(message.createdAt)}</span>
</div> </div>
{messageVersion && messageVersion.message && ( {messageVersion && messageVersion.message && versionNumber && (
<div className="flex items-center space-x-1"> <div className="flex items-center space-x-1">
<GitCommit className="h-3 w-3" /> <GitCommit className="h-3 w-3" />
{messageVersion && messageVersion.message && ( <span className="font-medium">{`Version ${versionNumber}:`}</span>
<span <span
className="max-w-50 truncate font-medium" className="max-w-50 truncate"
title={messageVersion.message} title={messageVersion.message}
> >
{ {
...@@ -297,7 +305,6 @@ const ChatMessage = ({ ...@@ -297,7 +305,6 @@ const ChatMessage = ({
.split("\n")[0] .split("\n")[0]
} }
</span> </span>
)}
</div> </div>
)} )}
{message.requestId && ( {message.requestId && (
......
...@@ -318,6 +318,23 @@ export function useStreamChat({ ...@@ -318,6 +318,23 @@ export function useStreamChat({
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: queryKeys.proposals.detail({ chatId }), queryKey: queryKeys.proposals.detail({ chatId }),
}); });
if (!response.wasCancelled) {
// Re-fetch messages to pick up server-assigned fields (e.g. commitHash)
// that may only be finalized at stream completion.
try {
const latestChat = await ipc.chat.getChat(chatId);
setMessagesById((prev) => {
const next = new Map(prev);
next.set(chatId, latestChat.messages);
return next;
});
} catch (error) {
console.warn(
`[CHAT] Failed to refresh latest chat for ${chatId}:`,
error,
);
}
}
invalidateChats(); invalidateChats();
refreshApp(); refreshApp();
refreshVersions(); refreshVersions();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论