Skip to content

Commit dda3e21

Browse files
authored
[front] - fix: assistant details modal (#9685)
* [front/components/assistant] - refactor: replace ElementModal with Sheet component in AssistantDetails - Introduced useState hook for tracking the Sheet's open state and useEffect hook to set this state based on the assistantId - Updated AssistantDetails to use the Sheet component for modal functionality, enhancing the UX with a new sliding panel design - Removed the now-obsolete ElementModal import and related attributes in favor of Sheet related components and attributes * [front/assistant] - refactor: streamline AssistantDetails component state management - Removed unused isOpen state variable and useEffect for setting modal open state - Modified conditionals to use optional chaining for cleaner access to agentConfiguration properties - Ensure Sheet component open state is dependent on the existence of an assistantId - Conditional rendering of the AssistantUsageSection now checks for the existence of agentConfiguration directly
1 parent 542c03b commit dda3e21

File tree

1 file changed

+40
-33
lines changed

1 file changed

+40
-33
lines changed

front/components/assistant/AssistantDetails.tsx

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import {
22
Avatar,
33
ContentMessage,
4-
ElementModal,
54
InformationCircleIcon,
65
Page,
6+
Sheet,
7+
SheetContainer,
8+
SheetContent,
9+
SheetHeader,
10+
SheetTitle,
711
} from "@dust-tt/sparkle";
812
import type { AgentConfigurationScope, WorkspaceType } from "@dust-tt/types";
913
import { useCallback, useState } from "react";
@@ -52,26 +56,24 @@ export function AssistantDetails({
5256
[doUpdateScope]
5357
);
5458

55-
if (!agentConfiguration) {
56-
return <></>;
57-
}
58-
5959
const DescriptionSection = () => (
6060
<div className="flex flex-col gap-5">
6161
<div className="flex flex-col gap-3 sm:flex-row">
6262
<Avatar
6363
name="Assistant avatar"
64-
visual={agentConfiguration.pictureUrl}
64+
visual={agentConfiguration?.pictureUrl}
6565
size="lg"
6666
/>
6767
<div className="flex grow flex-col gap-1">
6868
<div
6969
className={classNames(
7070
"font-bold text-foreground",
71-
agentConfiguration.name.length > 20 ? "text-md" : "text-lg"
71+
agentConfiguration?.name && agentConfiguration.name.length > 20
72+
? "text-md"
73+
: "text-lg"
7274
)}
73-
>{`@${agentConfiguration.name}`}</div>
74-
{agentConfiguration.status === "active" && (
75+
>{`@${agentConfiguration?.name ?? ""}`}</div>
76+
{agentConfiguration?.status === "active" && (
7577
<SharingDropdown
7678
owner={owner}
7779
agentConfiguration={agentConfiguration}
@@ -83,15 +85,15 @@ export function AssistantDetails({
8385
)}
8486
</div>
8587
</div>
86-
{agentConfiguration.status === "active" && (
88+
{agentConfiguration?.status === "active" && (
8789
<AssistantDetailsButtonBar
8890
owner={owner}
8991
agentConfiguration={agentConfiguration}
9092
isAgentConfigurationValidating={isAgentConfigurationValidating}
9193
/>
9294
)}
9395

94-
{agentConfiguration.status === "archived" && (
96+
{agentConfiguration?.status === "archived" && (
9597
<ContentMessage
9698
variant="amber"
9799
title="This assistant has been deleted."
@@ -103,18 +105,20 @@ export function AssistantDetails({
103105
)}
104106

105107
<div className="text-sm text-foreground">
106-
{agentConfiguration.description}
108+
{agentConfiguration?.description}
107109
</div>
108-
<AssistantUsageSection
109-
agentConfiguration={agentConfiguration}
110-
owner={owner}
111-
/>
110+
{agentConfiguration && (
111+
<AssistantUsageSection
112+
agentConfiguration={agentConfiguration}
113+
owner={owner}
114+
/>
115+
)}
112116
<Page.Separator />
113117
</div>
114118
);
115119

116120
const InstructionsSection = () =>
117-
agentConfiguration.instructions ? (
121+
agentConfiguration?.instructions ? (
118122
<div className="flex flex-col gap-2">
119123
<div className="text-lg font-bold text-element-800">Instructions</div>
120124
<ReadOnlyTextArea content={agentConfiguration.instructions} />
@@ -124,21 +128,24 @@ export function AssistantDetails({
124128
);
125129

126130
return (
127-
<ElementModal
128-
openOnElement={agentConfiguration}
129-
title=""
130-
onClose={() => onClose()}
131-
hasChanged={false}
132-
variant="side-sm"
133-
>
134-
<div className="flex flex-col gap-5 pt-6 text-sm text-foreground">
135-
<DescriptionSection />
136-
<AssistantActionsSection
137-
agentConfiguration={agentConfiguration}
138-
owner={owner}
139-
/>
140-
<InstructionsSection />
141-
</div>
142-
</ElementModal>
131+
<Sheet open={!!assistantId} onOpenChange={onClose}>
132+
<SheetContent size="lg">
133+
<SheetHeader>
134+
<SheetTitle />
135+
</SheetHeader>
136+
<SheetContainer>
137+
{agentConfiguration && (
138+
<div className="flex flex-col gap-5 pt-6 text-sm text-foreground">
139+
<DescriptionSection />
140+
<AssistantActionsSection
141+
agentConfiguration={agentConfiguration}
142+
owner={owner}
143+
/>
144+
<InstructionsSection />
145+
</div>
146+
)}
147+
</SheetContainer>
148+
</SheetContent>
149+
</Sheet>
143150
);
144151
}

0 commit comments

Comments
 (0)