Skip to content

Commit

Permalink
[Conversation UX] Remove tooltip on assistant mention (#5892)
Browse files Browse the repository at this point in the history
* [Conversation UX] Remove tooltip on assistant mention

* clean

* clean 2
  • Loading branch information
philipperolet authored Jun 26, 2024
1 parent 13f0b1d commit 0f4123b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 42 deletions.
41 changes: 6 additions & 35 deletions front/components/assistant/RenderMessageMarkdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@ import {
ClipboardIcon,
IconButton,
SparklesIcon,
Tooltip,
WrenchIcon,
} from "@dust-tt/sparkle";
import type {
LightAgentConfigurationType,
WebsearchResultType,
} from "@dust-tt/types";
import type { WebsearchResultType } from "@dust-tt/types";
import type { RetrievalDocumentType } from "@dust-tt/types";
import mermaid from "mermaid";
import dynamic from "next/dynamic";
Expand Down Expand Up @@ -175,12 +171,10 @@ export const CitationsContext = React.createContext<CitationsContextType>({
export function RenderMessageMarkdown({
content,
isStreaming,
agentConfigurations,
citationsContext,
}: {
content: string;
isStreaming: boolean;
agentConfigurations?: LightAgentConfigurationType[];
citationsContext?: CitationsContextType;
}) {
// Memoize markdown components to avoid unnecessary re-renders that disrupt text selection
Expand Down Expand Up @@ -236,19 +230,11 @@ export function RenderMessageMarkdown({
),
// @ts-expect-error - `mention` is a custom tag, currently refused by
// react-markdown types although the functionality is supported
mention: ({ agentName, agentSId }) => {
const agentConfiguration = agentConfigurations?.find(
(agentConfiguration) => agentConfiguration.sId === agentSId
);
return (
<MentionBlock
agentConfiguration={agentConfiguration}
agentName={agentName}
/>
);
mention: ({ agentName }) => {
return <MentionBlock agentName={agentName} />;
},
}),
[agentConfigurations, isStreaming]
[isStreaming]
);

const markdownPlugins = useMemo(
Expand Down Expand Up @@ -281,25 +267,10 @@ export function RenderMessageMarkdown({
);
}

function MentionBlock({
agentName,
agentConfiguration,
}: {
agentName: string;
agentConfiguration?: LightAgentConfigurationType;
}) {
const statusText =
!agentConfiguration || agentConfiguration?.status === "archived"
? "(This assistant was deleted)"
: agentConfiguration?.status === "active"
? ""
: "(This assistant is either deactivated or being tested)";
const tooltipLabel = agentConfiguration?.description || "" + " " + statusText;
function MentionBlock({ agentName }: { agentName: string }) {
return (
<span className="inline-block cursor-default font-medium text-brand">
<Tooltip label={tooltipLabel} position="below">
@{agentName}
</Tooltip>
@{agentName}
</span>
);
}
Expand Down
7 changes: 0 additions & 7 deletions front/components/assistant/conversation/UserMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { AgentSuggestion } from "@app/components/assistant/conversation/AgentSug
import type { MessageSizeType } from "@app/components/assistant/conversation/ConversationMessage";
import { ConversationMessage } from "@app/components/assistant/conversation/ConversationMessage";
import { RenderMessageMarkdown } from "@app/components/assistant/RenderMessageMarkdown";
import { useAgentConfigurations } from "@app/lib/swr";

interface UserMessageProps {
conversationId: string;
Expand All @@ -36,11 +35,6 @@ export function UserMessage({
contentFragments,
size,
}: UserMessageProps) {
const { agentConfigurations } = useAgentConfigurations({
workspaceId: owner.sId,
agentsGetView: { conversationId },
});

return (
<ConversationMessage
owner={owner}
Expand All @@ -61,7 +55,6 @@ export function UserMessage({
<RenderMessageMarkdown
content={message.content}
isStreaming={false}
agentConfigurations={agentConfigurations}
/>
</div>
{message.mentions.length === 0 && isLastMessage && (
Expand Down

0 comments on commit 0f4123b

Please sign in to comment.