Send chat message to Khoj web app via url query param

- This allows triggering khoj chat from the browser addressbar
- So now if you add Khoj to your browser bookmark with
  - URL: https://app.khoj.dev/?q=%s
  - Keyword: khoj

- Then you can type "khoj what is the news today" to trigger Khoj to
  quickly respond to your query. This avoids having to open the Khoj web
  app before asking your question
This commit is contained in:
Debanjum Singh Solanky
2024-09-15 18:54:58 -07:00
parent ecdbcd815e
commit bb2bd77a64

View File

@@ -22,6 +22,7 @@ import { getIconFromIconName } from "@/app/common/iconUtils";
import { AgentData } from "@/app/agents/page";
import { createNewConversation } from "./common/chatFunctions";
import { useIsMobileWidth } from "./common/utils";
import { useSearchParams } from "next/navigation";
interface ChatBodyDataProps {
chatOptionsData: ChatOptions | null;
@@ -51,6 +52,14 @@ function ChatBodyData(props: ChatBodyDataProps) {
const [agentIcons, setAgentIcons] = useState<JSX.Element[]>([]);
const [agents, setAgents] = useState<AgentData[]>([]);
const [showLoginPrompt, setShowLoginPrompt] = useState(false);
const searchParams = useSearchParams();
const queryParam = searchParams.get("q");
useEffect(() => {
if (queryParam) {
setMessage(decodeURIComponent(queryParam));
}
}, [queryParam]);
const onConversationIdChange = props.onConversationIdChange;