Skip to content

Commit 50ea02e

Browse files
committed
Add login dialog to AppRenderer.jsx on usage limit
1 parent 1aa7f80 commit 50ea02e

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

llmstack/client/src/components/apps/renderer/AppRenderer.jsx

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
import { axios } from "../../../data/axios";
2323
import { isLoggedInState, appRunDataState } from "../../../data/atoms";
2424
import { useSetRecoilState, useRecoilValue } from "recoil";
25+
import LoginDialog from "../../LoginDialog";
2526

2627
const defaultWorkflowLayout = `<pa-layout sx='{"maxWidth": "900px", "margin": "0 auto"}'>
2728
<pa-paper style="padding: 10px;">
@@ -53,6 +54,7 @@ const defaultChatLayout = `<pa-layout sx='{"maxWidth": "900px", "margin": "0 aut
5354
export function AppRenderer({ app, ws }) {
5455
const appSessionId = useRef(null);
5556
const [layout, setLayout] = useState("");
57+
const [showLoginDialog, setShowLoginDialog] = useState(false);
5658
const templateEngine = useMemo(() => new Liquid(), []);
5759

5860
const outputTemplate = templateEngine.parse(
@@ -282,6 +284,11 @@ export function AppRenderer({ app, ws }) {
282284
errors: ["Usage limit exceeded"],
283285
messages: messagesRef.current.get(),
284286
}));
287+
288+
// If the user is not logged in, show the login dialog
289+
if (!isLoggedIn) {
290+
setShowLoginDialog(true);
291+
}
285292
}
286293

287294
if (message.errors && message.errors.length > 0) {
@@ -419,8 +426,17 @@ export function AppRenderer({ app, ws }) {
419426
);
420427

421428
return (
422-
<MemoizedLayoutRenderer runApp={runApp} runProcessor={runProcessor}>
423-
{layout}
424-
</MemoizedLayoutRenderer>
429+
<>
430+
{showLoginDialog && (
431+
<LoginDialog
432+
open={showLoginDialog}
433+
handleClose={() => setShowLoginDialog(false)}
434+
redirectPath={window.location.pathname}
435+
/>
436+
)}
437+
<MemoizedLayoutRenderer runApp={runApp} runProcessor={runProcessor}>
438+
{layout}
439+
</MemoizedLayoutRenderer>
440+
</>
425441
);
426442
}

0 commit comments

Comments
 (0)