feat: improve the allow tool ui (#1473)

This commit is contained in:
Yingjie He
2025-03-03 13:42:49 -08:00
committed by GitHub
parent 426da76cd3
commit 7edb624bdc
3 changed files with 72 additions and 37 deletions
+9 -3
View File
@@ -9,7 +9,7 @@ import {
getTextContent,
getToolRequests,
getToolResponses,
getToolConfirmationRequestId,
getToolConfirmationContent,
} from '../types/message';
import ToolCallConfirmation from './ToolCallConfirmation';
@@ -36,7 +36,8 @@ export default function GooseMessage({ message, metadata, messages, append }: Go
const previousUrls = previousMessage ? extractUrls(getTextContent(previousMessage)) : [];
const urls = toolRequests.length === 0 ? extractUrls(textContent, previousUrls) : [];
const [toolConfirmationId, hasToolConfirmation] = getToolConfirmationRequestId(message);
const toolConfirmationContent = getToolConfirmationContent(message);
const hasToolConfirmation = toolConfirmationContent !== undefined;
// Find tool responses that correspond to the tool requests in this message
const toolResponsesMap = useMemo(() => {
@@ -72,7 +73,12 @@ export default function GooseMessage({ message, metadata, messages, append }: Go
</div>
)}
{hasToolConfirmation && <ToolCallConfirmation toolConfirmationId={toolConfirmationId} />}
{hasToolConfirmation && (
<ToolCallConfirmation
toolConfirmationId={toolConfirmationContent.id}
toolName={toolConfirmationContent.toolName}
/>
)}
{toolRequests.length > 0 && (
<div className="goose-message-tool bg-bgApp border border-borderSubtle dark:border-gray-700 rounded-b-2xl px-4 pt-4 pb-2 mt-1">