Skip to content

Commit

Permalink
devabot via url
Browse files Browse the repository at this point in the history
  • Loading branch information
lassejaco committed Nov 6, 2024
1 parent 3815d47 commit 1eb43d4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion devcon-app/src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ function App({ Component, pageProps }: AppProps) {
{sessions && (
<DevaBot
sessions={sessions}
onToggle={() => setDevaBotVisible(!devaBotVisible)}
onToggle={(message: string | boolean) => setDevaBotVisible(message)}
defaultPrompt={typeof devaBotVisible === 'string' ? devaBotVisible : undefined}
setDefaultPrompt={() => setDevaBotVisible(true)}
toggled={!!devaBotVisible}
Expand Down
14 changes: 13 additions & 1 deletion lib/components/ai/overlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const DevaBot = ({
recommendationMode?: boolean;
sessions?: any;
toggled: boolean;
onToggle: (visible: boolean) => void;
onToggle: (visible: string | boolean) => void;
notifications?: any[];
notificationsCount?: number;
renderNotifications?: () => React.ReactNode;
Expand Down Expand Up @@ -141,6 +141,18 @@ const DevaBot = ({
}
}, [defaultPrompt]);

useEffect(() => {
const urlParams = new URLSearchParams(window.location.search);
const devaBotPrompt = urlParams.get("devabot");

if (devaBotPrompt) {
onToggle(devaBotPrompt);
setTimeout(() => {
setQuery(devaBotPrompt);
}, 1000);
}
}, []);

// Add this useEffect hook to check screen size
React.useEffect(() => {
const checkScreenSize = () => {
Expand Down

0 comments on commit 1eb43d4

Please sign in to comment.