Merge branch 'main' into brace/fix-loading-onboarding

This commit is contained in:
Brace Sproul
2024-09-26 12:41:20 -07:00
committed by GitHub
2 changed files with 11 additions and 6 deletions
+2 -3
View File
@@ -1,8 +1,6 @@
"use client";
import { WelcomeDialog } from "@/components/WelcomeDialog";
import { useEffect, useState } from "react";
import { ASSISTANT_ID_COOKIE } from "@/constants";
import { getCookie, setCookie } from "@/lib/cookies";
import { useState } from "react";
import { useRules } from "@/hooks/useRules";
import { GeneratedRulesDialog } from "@/components/GeneratedRulesDialog";
import { ContentComposerChatInterface } from "@/components/ContentComposer";
@@ -72,6 +70,7 @@ export default function Home() {
systemRules={systemRules}
updateAssistantMetadata={updateAssistantMetadata}
assistantId={assistantId}
userId={userId}
/>
</main>
);
+9 -3
View File
@@ -145,6 +145,7 @@ export interface WelcomeDialogProps {
setSystemRulesAndSave: (newSystemRules: string) => Promise<void>;
setSystemRules: (newSystemRules: string) => void;
assistantId: string | undefined;
userId: string | undefined;
updateAssistantMetadata: (
assistantId: string,
fields: { metadata: Record<string, any> }
@@ -170,7 +171,7 @@ export function WelcomeDialog(props: WelcomeDialogProps) {
}
}, []);
const handleClose = () => {
const handleClose = async () => {
setCookie(HAS_SEEN_DIALOG, "true");
void setSystemRulesAndSave(systemRules ?? "");
if (assistantName || assistantDescription) {
@@ -179,14 +180,19 @@ export function WelcomeDialog(props: WelcomeDialogProps) {
"Unable to update assistant metadata: assistantId is undefined"
);
}
void props.updateAssistantMetadata(props.assistantId, {
if (!props.userId) {
throw new Error("Can not save assistant if userId is undefined.");
}
setOpen(false);
await props.updateAssistantMetadata(props.assistantId, {
metadata: {
assistantName,
assistantDescription,
userId: props.userId,
},
});
}
setOpen(false);
};
const handleNext = () => {