diff --git a/apps/dashboard/src/app/nebula-app/(app)/api/chat.ts b/apps/dashboard/src/app/nebula-app/(app)/api/chat.ts index 9c4f29bf723..78147d23038 100644 --- a/apps/dashboard/src/app/nebula-app/(app)/api/chat.ts +++ b/apps/dashboard/src/app/nebula-app/(app)/api/chat.ts @@ -13,7 +13,7 @@ export type ContextFilters = { export async function promptNebula(params: { message: string; sessionId: string; - config: ExecuteConfig; + config: ExecuteConfig | null; authToken: string; handleStream: (res: ChatStreamedResponse) => void; abortController: AbortController; @@ -24,7 +24,6 @@ export async function promptNebula(params: { user_id: "default-user", session_id: params.sessionId, stream: true, - execute_config: params.config, }; if (params.contextFilters) { @@ -34,6 +33,10 @@ export async function promptNebula(params: { }; } + if (params.config) { + body.execute_config = params.config; + } + const events = await stream(`${NEXT_PUBLIC_NEBULA_URL}/chat`, { method: "POST", headers: { diff --git a/apps/dashboard/src/app/nebula-app/(app)/chat/[session_id]/page.tsx b/apps/dashboard/src/app/nebula-app/(app)/chat/[session_id]/page.tsx index 8c12a9da38f..75d0c4f5de3 100644 --- a/apps/dashboard/src/app/nebula-app/(app)/chat/[session_id]/page.tsx +++ b/apps/dashboard/src/app/nebula-app/(app)/chat/[session_id]/page.tsx @@ -1,9 +1,6 @@ import { redirect } from "next/navigation"; import { getValidAccount } from "../../../../account/settings/getAccount"; -import { - getAuthToken, - getAuthTokenWalletAddress, -} from "../../../../api/lib/getAuthToken"; +import { getAuthToken } from "../../../../api/lib/getAuthToken"; import { loginRedirect } from "../../../../login/loginRedirect"; import { getSessionById } from "../../api/session"; import { ChatPageContent } from "../../components/ChatPageContent"; @@ -22,12 +19,6 @@ export default async function Page(props: { loginRedirect(pagePath); } - const accountAddress = await getAuthTokenWalletAddress(); - - if (!accountAddress) { - loginRedirect(pagePath); - } - const session = await getSessionById({ authToken, sessionId: params.session_id, @@ -39,7 +30,6 @@ export default async function Page(props: { return ( { - if ( - !isNewSession || - hasUserUpdatedContextFilters || - !address || - !activeChain - ) { + if (!isNewSession || hasUserUpdatedContextFilters) { return; } @@ -109,19 +114,23 @@ export function ChatPageContent(props: { ? { ..._contextFilters } : {}; - updatedContextFilters.walletAddresses = [address]; - updatedContextFilters.chainIds = [activeChain.id.toString()]; + updatedContextFilters.walletAddresses = address ? [address] : []; + updatedContextFilters.chainIds = activeChain + ? [activeChain.id.toString()] + : []; return updatedContextFilters; }); }, [address, isNewSession, hasUserUpdatedContextFilters, activeChain]); - const config: ExecuteConfig = useMemo(() => { - return { - mode: "client", - signer_wallet_address: props.accountAddress, - }; - }, [props.accountAddress]); + const config: ExecuteConfig | null = useMemo(() => { + return address + ? { + mode: "client", + signer_wallet_address: address, + } + : null; + }, [address]); const [sessionId, _setSessionId] = useState( props.session?.id, @@ -150,6 +159,7 @@ export function ChatPageContent(props: { const [isChatStreaming, setIsChatStreaming] = useState(false); const [enableAutoScroll, setEnableAutoScroll] = useState(false); + const [showConnectModal, setShowConnectModal] = useState(false); const initSession = useCallback(async () => { const session = await createSession({ @@ -163,6 +173,10 @@ export function ChatPageContent(props: { const handleSendMessage = useCallback( async (message: string) => { + if (!address) { + setShowConnectModal(true); + return; + } setUserHasSubmittedMessage(true); setMessages((prev) => [ ...prev, @@ -329,6 +343,7 @@ export function ChatPageContent(props: { props.authToken, messages.length, initSession, + address, ], ); @@ -350,6 +365,10 @@ export function ChatPageContent(props: { return (
+
); } + +function WalletDisconnectedDialog(props: { + open: boolean; + onOpenChange: (value: boolean) => void; +}) { + return ( + + +
+ + Wallet Disconnected + + Connect your wallet to continue + + +
+ +
+ + + + +
+
+
+ ); +} diff --git a/apps/dashboard/src/app/nebula-app/(app)/page.tsx b/apps/dashboard/src/app/nebula-app/(app)/page.tsx index adde8c1b4fd..e86bfda456e 100644 --- a/apps/dashboard/src/app/nebula-app/(app)/page.tsx +++ b/apps/dashboard/src/app/nebula-app/(app)/page.tsx @@ -1,8 +1,5 @@ import { getValidAccount } from "../../account/settings/getAccount"; -import { - getAuthToken, - getAuthTokenWalletAddress, -} from "../../api/lib/getAuthToken"; +import { getAuthToken } from "../../api/lib/getAuthToken"; import { loginRedirect } from "../../login/loginRedirect"; import { ChatPageContent } from "./components/ChatPageContent"; @@ -20,16 +17,10 @@ export default async function Page(props: { loginRedirect(); } - const accountAddress = await getAuthTokenWalletAddress(); const account = await getValidAccount(); - if (!accountAddress) { - loginRedirect(); - } - return ( (undefined); - const [showLoginPage, setShowLoginPage] = useState(false); - + const [showPage, setShowPage] = useState<"connect" | "welcome">( + props.account ? "connect" : "welcome", + ); return (
+ {/* nav */}
@@ -37,8 +39,8 @@ export function NebulaLoginPage(props: { Docs - {!showLoginPage && ( - )} @@ -46,19 +48,21 @@ export function NebulaLoginPage(props: {
- {showLoginPage ? ( + {showPage === "connect" && ( - ) : ( + )} + + {showPage === "welcome" && (
{ setMessage(msg); - setShowLoginPage(true); + setShowPage("connect"); }} />