Skip to content

Commit

Permalink
Merge branch 'main' into aric-streaming_relaxed
Browse files Browse the repository at this point in the history
  • Loading branch information
lasryaric authored Sep 29, 2023
2 parents b12941f + e449a83 commit 6b9608f
Show file tree
Hide file tree
Showing 71 changed files with 1,068 additions and 382 deletions.
423 changes: 405 additions & 18 deletions docs/src/pages/conversations.mdx

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion front/components/ConnectorPermissionsModal.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Checkbox, Modal } from "@dust-tt/sparkle";
import { Cog6ToothIcon } from "@heroicons/react/20/solid";
import { useState } from "react";
import { mutate } from "swr";
import { useSWRConfig } from "swr";

import { CONNECTOR_CONFIGURATIONS } from "@app/lib/connector_providers";
import {
Expand Down Expand Up @@ -63,6 +63,8 @@ export default function ConnectorPermissionsModal({
setOpen: (open: boolean) => void;
onEditPermission: () => void;
}) {
const { mutate } = useSWRConfig();

const [updatedPermissionByInternalId, setUpdatedPermissionByInternalId] =
useState<Record<string, ConnectorPermission>>({});

Expand Down
44 changes: 43 additions & 1 deletion front/components/assistant/conversation/Conversation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,24 @@ import {
} from "@app/lib/api/assistant/conversation";
import { useConversation, useConversations } from "@app/lib/swr";
import {
AgentMention,
AgentMessageType,
isAgentMention,
isUserMessageType,
UserMessageType,
} from "@app/types/assistant/conversation";
import { WorkspaceType } from "@app/types/user";
import { UserType, WorkspaceType } from "@app/types/user";

export default function Conversation({
owner,
user,
conversationId,
onStickyMentionsChange,
}: {
owner: WorkspaceType;
user: UserType;
conversationId: string;
onStickyMentionsChange?: (mentions: AgentMention[]) => void;
}) {
const {
conversation,
Expand Down Expand Up @@ -50,6 +57,41 @@ export default function Conversation({
}
}, [conversation?.content.length]);

useEffect(() => {
if (!onStickyMentionsChange) {
return;
}
const lastUserMessageContent = conversation?.content.findLast(
(versionedMessages) =>
versionedMessages.some(
(message) =>
isUserMessageType(message) &&
message.visibility !== "deleted" &&
message.user?.id === user.id
)
);

if (!lastUserMessageContent) {
return;
}

const lastUserMessage =
lastUserMessageContent[lastUserMessageContent.length - 1];

if (!lastUserMessage || !isUserMessageType(lastUserMessage)) {
return;
}

const mentions = lastUserMessage.mentions;
const agentMentions = mentions.filter(isAgentMention);
onStickyMentionsChange(agentMentions);
}, [
conversation?.content,
conversation?.content.length,
onStickyMentionsChange,
user.id,
]);

const buildEventSourceURL = useCallback(
(lastEvent: string | null) => {
if (!lastConversationTs) {
Expand Down
137 changes: 68 additions & 69 deletions front/components/assistant/conversation/ConversationTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ export function ConversationTitle({
<span className="font-bold">{conversation?.title || ""}</span>
</div>

<div className="flex gap-2">
<div className="flex items-center gap-6">
<div className="hidden lg:flex">
<Avatar.Stack
size="md"
size="sm"
nbMoreItems={
conversation.participants.agents.length > 4
? conversation.participants.agents.length - 4
Expand All @@ -65,14 +65,13 @@ export function ConversationTitle({
visual={agent.pictureUrl}
size="md"
key={agent.configurationId}
isRounded
/>
))}
</Avatar.Stack>
</div>
<div className="hidden lg:flex">
<Avatar.Stack
size="md"
size="sm"
nbMoreItems={
conversation.participants.users.length > 4
? conversation.participants.users.length - 4
Expand All @@ -85,83 +84,83 @@ export function ConversationTitle({
visual={user.pictureUrl}
size="md"
key={i}
isRounded
/>
))}
</Avatar.Stack>
</div>

<div className="hidden lg:flex">
{onDelete && (
<DropdownMenu>
<DropdownMenu.Button>
<Button
size="sm"
labelVisible={false}
tooltipPosition="below"
variant="secondaryWarning"
label="Delete Conversation"
icon={TrashIcon}
/>
</DropdownMenu.Button>
<DropdownMenu.Items width={280}>
<div className="flex flex-col gap-y-4 px-4 py-4">
<div className="flex flex-col gap-y-2">
<div className="grow text-sm font-medium text-element-800">
Are you sure you want to delete?
</div>
<Button.List>
<div className="hidden lg:flex">
{onDelete && (
<DropdownMenu>
<DropdownMenu.Button>
<Button
size="sm"
labelVisible={false}
tooltipPosition="below"
variant="secondaryWarning"
label="Delete Conversation"
icon={TrashIcon}
/>
</DropdownMenu.Button>
<DropdownMenu.Items width={280}>
<div className="flex flex-col gap-y-4 px-4 py-4">
<div className="flex flex-col gap-y-2">
<div className="grow text-sm font-medium text-element-800">
Are you sure you want to delete?
</div>

<div className="text-sm font-normal text-element-700">
This will delete the conversation for everyone.
<div className="text-sm font-normal text-element-700">
This will delete the conversation for everyone.
</div>
</div>
<div className="flex justify-center">
<Button
variant="primaryWarning"
size="sm"
label={"Delete for Everyone"}
icon={TrashIcon}
onClick={onDelete}
/>
</div>
</div>
<div className="flex justify-center">
<Button
variant="primaryWarning"
size="sm"
label={"Delete for Everyone"}
icon={TrashIcon}
onClick={onDelete}
/>
</DropdownMenu.Items>
</DropdownMenu>
)}
</div>
<DropdownMenu>
<DropdownMenu.Button>
<Button
size="sm"
label="Share"
icon={ArrowUpOnSquareIcon}
variant="secondary"
/>
</DropdownMenu.Button>
<DropdownMenu.Items width={280}>
<div className="flex flex-col gap-y-4 p-4">
<div className="flex flex-col gap-y-2">
<div className="grow text-sm font-medium text-element-800">
Share this conversation with others
</div>
<div className="text-sm font-normal text-element-700">
Share the conversation link with other members of your
workspace to invite them to contribute.
</div>
</div>
</DropdownMenu.Items>
</DropdownMenu>
)}
</div>

<DropdownMenu>
<DropdownMenu.Button>
<Button
size="sm"
label="Share"
icon={ArrowUpOnSquareIcon}
variant="secondary"
/>
</DropdownMenu.Button>
<DropdownMenu.Items width={280}>
<div className="flex flex-col gap-y-4 p-4">
<div className="flex flex-col gap-y-2">
<div className="grow text-sm font-medium text-element-800">
Share this conversation with others
</div>
<div className="text-sm font-normal text-element-700">
Share the conversation link with other members of your
workspace to invite them to contribute.
<div className="flex justify-center">
<Button
variant="secondary"
size="sm"
label={copyLinkSuccess ? "Copied!" : "Copy the link"}
icon={copyLinkSuccess ? ClipboardCheckIcon : LinkStrokeIcon}
onClick={handleClick}
/>
</div>
</div>
<div className="flex justify-center">
<Button
variant="secondary"
size="sm"
label={copyLinkSuccess ? "Copied!" : "Copy the link"}
icon={copyLinkSuccess ? ClipboardCheckIcon : LinkStrokeIcon}
onClick={handleClick}
/>
</div>
</div>
</DropdownMenu.Items>
</DropdownMenu>
</DropdownMenu.Items>
</DropdownMenu>
</Button.List>
</div>
</div>
);
Expand Down
Loading

0 comments on commit 6b9608f

Please sign in to comment.