Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove new conversation input bar animation #9534

Merged
merged 2 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 18 additions & 47 deletions front/components/assistant/conversation/ConversationContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,12 @@ export function ConversationContainer({
});
} else {
// We start the push before creating the message to optimize for instantaneity as well.
setActiveConversationId(conversationRes.value.sId);
void router.push(
await router.push(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

required so that we snap once the shallow URL change is done so that everyone snap at the same time (title in, conversation in, assistant out)

`/w/${owner.sId}/assistant/${conversationRes.value.sId}`,
undefined,
{ shallow: true }
);
setActiveConversationId(conversationRes.value.sId);

return new Ok(undefined);
}
Expand Down Expand Up @@ -287,47 +287,27 @@ export function ConversationContainer({
description="Drag and drop your text files (txt, doc, pdf) and image files (jpg, png) here."
title="Attach files to the conversation"
>
<Transition
show={!!activeConversationId}
as={Fragment}
enter="transition-all duration-300 ease-out"
enterFrom="flex-none w-full h-0"
enterTo="flex flex-1 w-full"
leave="transition-all duration-0 ease-out"
leaveFrom="flex flex-1 w-full"
leaveTo="flex-none w-full h-0"
>
{activeConversationId ? (
<ConversationViewer
owner={owner}
user={user}
conversationId={activeConversationId}
// TODO(2024-06-20 flav): Fix extra-rendering loop with sticky mentions.
onStickyMentionsChange={onStickyMentionsChange}
/>
) : (
<div></div>
)}
</Transition>

<Transition
as={Fragment}
show={!activeConversationId}
enter="transition-opacity duration-100 ease-out"
enterFrom="opacity-0 min-h-[20vh]"
enterTo="opacity-100"
leave="transition-opacity duration-100 ease-out"
leaveFrom="opacity-100"
leaveTo="opacity-0 min-h-[20vh]"
>
{activeConversationId ? (
<ConversationViewer
owner={owner}
user={user}
conversationId={activeConversationId}
// TODO(2024-06-20 flav): Fix extra-rendering loop with sticky mentions.
onStickyMentionsChange={onStickyMentionsChange}
/>
) : (
<div></div>
)}

{!activeConversationId && (
<div
id="assistant-input-header"
className="flex h-fit min-h-[20vh] w-full max-w-4xl flex-col justify-end gap-8 px-4 py-2"
>
<Page.Header title={greeting} />
<Page.SectionHeader title="Start a conversation" />
</div>
</Transition>
)}

<FixedAssistantInputBar
owner={owner}
Expand All @@ -338,16 +318,7 @@ export function ConversationContainer({
conversationId={activeConversationId}
/>

<Transition
show={!activeConversationId}
enter="transition-opacity duration-100 ease-out"
enterFrom="opacity-0"
enterTo="opacity-100"
leave="transition-opacity duration-100 ease-out"
leaveFrom="opacity-100"
leaveTo="opacity-0"
className={"flex w-full justify-center"}
>
{!activeConversationId && (
<AssistantBrowserContainer
onAgentConfigurationClick={setInputbarMention}
setAssistantToMention={(assistant) => {
Expand All @@ -356,7 +327,7 @@ export function ConversationContainer({
owner={owner}
isBuilder={isBuilder}
/>
</Transition>
)}

<ReachedLimitPopup
isOpened={planLimitReached}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,10 @@ export default function ConversationLayout({
}
titleChildren={
// TODO: Improve so we don't re-render everytime.
conversation && (
activeConversationId && (
<ConversationTitle
owner={owner}
conversationId={activeConversationId}
conversation={conversation}
shareLink={`${baseUrl}/w/${owner.sId}/assistant/${activeConversationId}`}
onDelete={onDeleteConversation}
Expand Down
16 changes: 9 additions & 7 deletions front/components/assistant/conversation/ConversationTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ import { classNames } from "@app/lib/utils";

export function ConversationTitle({
owner,
conversationId,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can have a conversationId before we have a conversation (shallow page change before the swr hook is executed)

conversation,
shareLink,
onDelete,
}: {
owner: WorkspaceType;
conversation: ConversationType;
conversationId: string;
conversation: ConversationType | null;
shareLink: string;
onDelete?: (conversationId: string) => void;
}) {
Expand All @@ -52,7 +54,7 @@ export function ConversationTitle({
const onTitleChange = async (title: string) => {
try {
const res = await fetch(
`/api/w/${owner.sId}/assistant/conversations/${conversation.sId}`,
`/api/w/${owner.sId}/assistant/conversations/${conversationId}`,
{
method: "PATCH",
headers: {
Expand All @@ -65,7 +67,7 @@ export function ConversationTitle({
}
);
await mutate(
`/api/w/${owner.sId}/assistant/conversations/${conversation.sId}`
`/api/w/${owner.sId}/assistant/conversations/${conversationId}`
);
void mutate(`/api/w/${owner.sId}/assistant/conversations`);
if (!res.ok) {
Expand All @@ -86,15 +88,15 @@ export function ConversationTitle({
onClose={() => setShowDeleteDialog(false)}
onDelete={() => {
setShowDeleteDialog(false);
onDelete(conversation.sId);
onDelete(conversationId);
}}
/>
)}
<div className="grid h-full min-w-0 max-w-full grid-cols-[1fr,auto] items-center gap-4">
<div className="flex min-w-0 flex-row items-center gap-4">
{!isEditingTitle ? (
<div className="min-w-0 overflow-hidden truncate">
<span className="font-bold">{conversation.title || ""}</span>
<span className="font-bold">{conversation?.title || ""}</span>
</div>
) : (
<div className="w-[84%]">
Expand Down Expand Up @@ -162,7 +164,7 @@ export function ConversationTitle({
<IconButton
icon={PencilSquareIcon}
onClick={() => {
setEditedTitle(conversation.title || "");
setEditedTitle(conversation?.title || "");
setIsEditingTitle(true);
}}
size="sm"
Expand All @@ -173,7 +175,7 @@ export function ConversationTitle({
<div className="flex items-center">
<div className="hidden pr-6 lg:flex">
<ConversationParticipants
conversationId={conversation.sId}
conversationId={conversationId}
owner={owner}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ export function AssistantInputBar({
...new Set(rawMentions.map((mention) => mention.id)),
].map((id) => ({ configurationId: id }));

// When we are creating a new conversation, we will disable the input bar, show a loading spinner and in case of error, re-enable the input bar
// When we are creating a new conversation, we will disable the input bar, show a loading
// spinner and in case of error, re-enable the input bar
if (!conversationId) {
setLoading(true);
setDisableSendButton(true);
Expand Down Expand Up @@ -237,7 +238,7 @@ export function AssistantInputBar({
}),
}
);
await mutateConversation();
mutateConversation();
};

useEffect(() => {
Expand Down
Loading