Skip to content

Commit 627b312

Browse files
committed
Open the AI widget if there’s a URL param
1 parent 5d7f3c8 commit 627b312

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

apps/webapp/app/components/navigation/SideMenu.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
ServerStackIcon,
1818
Squares2X2Icon,
1919
} from "@heroicons/react/20/solid";
20-
import { useNavigation } from "@remix-run/react";
20+
import { useLocation, useNavigation } from "@remix-run/react";
2121
import { useEffect, useRef, useState, type ReactNode } from "react";
2222
import simplur from "simplur";
2323
import { RunsIconExtraSmall } from "~/assets/icons/RunsIcon";
@@ -551,6 +551,19 @@ function SelectorDivider() {
551551

552552
function HelpAndAI() {
553553
const { isKapaEnabled, openKapa, isKapaOpen } = useKapaWidget();
554+
const location = useLocation();
555+
556+
// If the location searchParams contains `aiHelp="A question to ask AI"` we should get the value, clear it from the searchParams and open Kapa with the question
557+
const searchParams = new URLSearchParams(location.search);
558+
559+
useEffect(() => {
560+
const aiHelp = searchParams.get("aiHelp");
561+
if (aiHelp) {
562+
searchParams.delete("aiHelp");
563+
console.log("aiHelp", aiHelp);
564+
openKapa(aiHelp);
565+
}
566+
}, [location.search]);
554567

555568
return (
556569
<>

0 commit comments

Comments
 (0)