Skip to content

Commit 97902e7

Browse files
authored
Remove new conversation input bar animation (#9534)
* Remove new conversation input bar animation * imports
1 parent a790fbd commit 97902e7

File tree

4 files changed

+33
-66
lines changed

4 files changed

+33
-66
lines changed

front/components/assistant/conversation/ConversationContainer.tsx

Lines changed: 19 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,8 @@ import type {
1111
} from "@dust-tt/types";
1212
import type { UploadedContentFragment } from "@dust-tt/types";
1313
import { Err, Ok } from "@dust-tt/types";
14-
import { Transition } from "@headlessui/react";
1514
import { useRouter } from "next/router";
16-
import {
17-
Fragment,
18-
useCallback,
19-
useContext,
20-
useEffect,
21-
useRef,
22-
useState,
23-
} from "react";
15+
import { useCallback, useContext, useEffect, useRef, useState } from "react";
2416

2517
import { ReachedLimitPopup } from "@app/components/app/ReachedLimitPopup";
2618
import { AssistantBrowserContainer } from "@app/components/assistant/conversation/AssistantBrowserContainer";
@@ -231,12 +223,12 @@ export function ConversationContainer({
231223
});
232224
} else {
233225
// We start the push before creating the message to optimize for instantaneity as well.
234-
setActiveConversationId(conversationRes.value.sId);
235-
void router.push(
226+
await router.push(
236227
`/w/${owner.sId}/assistant/${conversationRes.value.sId}`,
237228
undefined,
238229
{ shallow: true }
239230
);
231+
setActiveConversationId(conversationRes.value.sId);
240232

241233
return new Ok(undefined);
242234
}
@@ -287,47 +279,27 @@ export function ConversationContainer({
287279
description="Drag and drop your text files (txt, doc, pdf) and image files (jpg, png) here."
288280
title="Attach files to the conversation"
289281
>
290-
<Transition
291-
show={!!activeConversationId}
292-
as={Fragment}
293-
enter="transition-all duration-300 ease-out"
294-
enterFrom="flex-none w-full h-0"
295-
enterTo="flex flex-1 w-full"
296-
leave="transition-all duration-0 ease-out"
297-
leaveFrom="flex flex-1 w-full"
298-
leaveTo="flex-none w-full h-0"
299-
>
300-
{activeConversationId ? (
301-
<ConversationViewer
302-
owner={owner}
303-
user={user}
304-
conversationId={activeConversationId}
305-
// TODO(2024-06-20 flav): Fix extra-rendering loop with sticky mentions.
306-
onStickyMentionsChange={onStickyMentionsChange}
307-
/>
308-
) : (
309-
<div></div>
310-
)}
311-
</Transition>
312-
313-
<Transition
314-
as={Fragment}
315-
show={!activeConversationId}
316-
enter="transition-opacity duration-100 ease-out"
317-
enterFrom="opacity-0 min-h-[20vh]"
318-
enterTo="opacity-100"
319-
leave="transition-opacity duration-100 ease-out"
320-
leaveFrom="opacity-100"
321-
leaveTo="opacity-0 min-h-[20vh]"
322-
>
282+
{activeConversationId ? (
283+
<ConversationViewer
284+
owner={owner}
285+
user={user}
286+
conversationId={activeConversationId}
287+
// TODO(2024-06-20 flav): Fix extra-rendering loop with sticky mentions.
288+
onStickyMentionsChange={onStickyMentionsChange}
289+
/>
290+
) : (
291+
<div></div>
292+
)}
293+
294+
{!activeConversationId && (
323295
<div
324296
id="assistant-input-header"
325297
className="flex h-fit min-h-[20vh] w-full max-w-4xl flex-col justify-end gap-8 px-4 py-2"
326298
>
327299
<Page.Header title={greeting} />
328300
<Page.SectionHeader title="Start a conversation" />
329301
</div>
330-
</Transition>
302+
)}
331303

332304
<FixedAssistantInputBar
333305
owner={owner}
@@ -338,16 +310,7 @@ export function ConversationContainer({
338310
conversationId={activeConversationId}
339311
/>
340312

341-
<Transition
342-
show={!activeConversationId}
343-
enter="transition-opacity duration-100 ease-out"
344-
enterFrom="opacity-0"
345-
enterTo="opacity-100"
346-
leave="transition-opacity duration-100 ease-out"
347-
leaveFrom="opacity-100"
348-
leaveTo="opacity-0"
349-
className={"flex w-full justify-center"}
350-
>
313+
{!activeConversationId && (
351314
<AssistantBrowserContainer
352315
onAgentConfigurationClick={setInputbarMention}
353316
setAssistantToMention={(assistant) => {
@@ -356,7 +319,7 @@ export function ConversationContainer({
356319
owner={owner}
357320
isBuilder={isBuilder}
358321
/>
359-
</Transition>
322+
)}
360323

361324
<ReachedLimitPopup
362325
isOpened={planLimitReached}

front/components/assistant/conversation/ConversationLayout.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,10 @@ export default function ConversationLayout({
118118
}
119119
titleChildren={
120120
// TODO: Improve so we don't re-render everytime.
121-
conversation && (
121+
activeConversationId && (
122122
<ConversationTitle
123123
owner={owner}
124+
conversationId={activeConversationId}
124125
conversation={conversation}
125126
shareLink={`${baseUrl}/w/${owner.sId}/assistant/${activeConversationId}`}
126127
onDelete={onDeleteConversation}

front/components/assistant/conversation/ConversationTitle.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@ import { classNames } from "@app/lib/utils";
2222

2323
export function ConversationTitle({
2424
owner,
25+
conversationId,
2526
conversation,
2627
shareLink,
2728
onDelete,
2829
}: {
2930
owner: WorkspaceType;
30-
conversation: ConversationType;
31+
conversationId: string;
32+
conversation: ConversationType | null;
3133
shareLink: string;
3234
onDelete?: (conversationId: string) => void;
3335
}) {
@@ -52,7 +54,7 @@ export function ConversationTitle({
5254
const onTitleChange = async (title: string) => {
5355
try {
5456
const res = await fetch(
55-
`/api/w/${owner.sId}/assistant/conversations/${conversation.sId}`,
57+
`/api/w/${owner.sId}/assistant/conversations/${conversationId}`,
5658
{
5759
method: "PATCH",
5860
headers: {
@@ -65,7 +67,7 @@ export function ConversationTitle({
6567
}
6668
);
6769
await mutate(
68-
`/api/w/${owner.sId}/assistant/conversations/${conversation.sId}`
70+
`/api/w/${owner.sId}/assistant/conversations/${conversationId}`
6971
);
7072
void mutate(`/api/w/${owner.sId}/assistant/conversations`);
7173
if (!res.ok) {
@@ -86,15 +88,15 @@ export function ConversationTitle({
8688
onClose={() => setShowDeleteDialog(false)}
8789
onDelete={() => {
8890
setShowDeleteDialog(false);
89-
onDelete(conversation.sId);
91+
onDelete(conversationId);
9092
}}
9193
/>
9294
)}
9395
<div className="grid h-full min-w-0 max-w-full grid-cols-[1fr,auto] items-center gap-4">
9496
<div className="flex min-w-0 flex-row items-center gap-4">
9597
{!isEditingTitle ? (
9698
<div className="min-w-0 overflow-hidden truncate">
97-
<span className="font-bold">{conversation.title || ""}</span>
99+
<span className="font-bold">{conversation?.title || ""}</span>
98100
</div>
99101
) : (
100102
<div className="w-[84%]">
@@ -162,7 +164,7 @@ export function ConversationTitle({
162164
<IconButton
163165
icon={PencilSquareIcon}
164166
onClick={() => {
165-
setEditedTitle(conversation.title || "");
167+
setEditedTitle(conversation?.title || "");
166168
setIsEditingTitle(true);
167169
}}
168170
size="sm"
@@ -173,7 +175,7 @@ export function ConversationTitle({
173175
<div className="flex items-center">
174176
<div className="hidden pr-6 lg:flex">
175177
<ConversationParticipants
176-
conversationId={conversation.sId}
178+
conversationId={conversationId}
177179
owner={owner}
178180
/>
179181
</div>

front/components/assistant/conversation/input_bar/InputBar.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ export function AssistantInputBar({
168168
...new Set(rawMentions.map((mention) => mention.id)),
169169
].map((id) => ({ configurationId: id }));
170170

171-
// 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
171+
// When we are creating a new conversation, we will disable the input bar, show a loading
172+
// spinner and in case of error, re-enable the input bar
172173
if (!conversationId) {
173174
setLoading(true);
174175
setDisableSendButton(true);
@@ -237,7 +238,7 @@ export function AssistantInputBar({
237238
}),
238239
}
239240
);
240-
await mutateConversation();
241+
mutateConversation();
241242
};
242243

243244
useEffect(() => {

0 commit comments

Comments
 (0)