Enhancement: Extension name tooltips for tool banners (#3250)
This commit is contained in:
@@ -7,6 +7,7 @@ import { cn, snakeToTitleCase } from '../utils';
|
|||||||
import Dot, { LoadingStatus } from './ui/Dot';
|
import Dot, { LoadingStatus } from './ui/Dot';
|
||||||
import { NotificationEvent } from '../hooks/useMessageStream';
|
import { NotificationEvent } from '../hooks/useMessageStream';
|
||||||
import { ChevronRight, LoaderCircle } from 'lucide-react';
|
import { ChevronRight, LoaderCircle } from 'lucide-react';
|
||||||
|
import { TooltipWrapper } from './settings/providers/subcomponents/buttons/TooltipWrapper';
|
||||||
|
|
||||||
interface ToolCallWithResponseProps {
|
interface ToolCallWithResponseProps {
|
||||||
isCancelledMessage: boolean;
|
isCancelledMessage: boolean;
|
||||||
@@ -121,6 +122,17 @@ const logToString = (logMessage: NotificationEvent) => {
|
|||||||
const notificationToProgress = (notification: NotificationEvent): Progress =>
|
const notificationToProgress = (notification: NotificationEvent): Progress =>
|
||||||
notification.message.params as unknown as Progress;
|
notification.message.params as unknown as Progress;
|
||||||
|
|
||||||
|
// Helper function to extract extension name for tooltip
|
||||||
|
const getExtensionTooltip = (toolCallName: string): string | null => {
|
||||||
|
const lastIndex = toolCallName.lastIndexOf('__');
|
||||||
|
if (lastIndex === -1) return null;
|
||||||
|
|
||||||
|
const extensionName = toolCallName.substring(0, lastIndex);
|
||||||
|
if (!extensionName) return null;
|
||||||
|
|
||||||
|
return `${extensionName} extension`;
|
||||||
|
};
|
||||||
|
|
||||||
function ToolCallView({
|
function ToolCallView({
|
||||||
isCancelledMessage,
|
isCancelledMessage,
|
||||||
toolCall,
|
toolCall,
|
||||||
@@ -387,6 +399,25 @@ function ToolCallView({
|
|||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Get extension tooltip for the current tool
|
||||||
|
const extensionTooltip = getExtensionTooltip(toolCall.name);
|
||||||
|
|
||||||
|
// Extract tool label content to avoid duplication
|
||||||
|
const getToolLabelContent = () => {
|
||||||
|
const description = getToolDescription();
|
||||||
|
if (description) {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
// Fallback tool name formatting
|
||||||
|
return snakeToTitleCase(toolCall.name.substring(toolCall.name.lastIndexOf('__') + 2));
|
||||||
|
};
|
||||||
|
|
||||||
|
const toolLabel = (
|
||||||
|
<span className={cn("ml-2", extensionTooltip && "cursor-pointer hover:opacity-80")}>
|
||||||
|
{getToolLabelContent()}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ToolCallExpandable
|
<ToolCallExpandable
|
||||||
isStartExpanded={isRenderingProgress}
|
isStartExpanded={isRenderingProgress}
|
||||||
@@ -400,16 +431,13 @@ function ToolCallView({
|
|||||||
<Dot size={2} loadingStatus={loadingStatus} />
|
<Dot size={2} loadingStatus={loadingStatus} />
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<span className="ml-2">
|
{extensionTooltip ? (
|
||||||
{(() => {
|
<TooltipWrapper tooltipContent={extensionTooltip} side="top" align="start">
|
||||||
const description = getToolDescription();
|
{toolLabel}
|
||||||
if (description) {
|
</TooltipWrapper>
|
||||||
return description;
|
) : (
|
||||||
}
|
toolLabel
|
||||||
// Fallback tool name formatting
|
)}
|
||||||
return snakeToTitleCase(toolCall.name.substring(toolCall.name.lastIndexOf('__') + 2));
|
|
||||||
})()}
|
|
||||||
</span>
|
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user