mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-02 04:12:47 +02:00
navigate directly to chat with search space id
This commit is contained in:
parent
98e12dd195
commit
06f02fba0a
1 changed files with 14 additions and 6 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
|
import { useAtomValue } from "jotai";
|
||||||
import {
|
import {
|
||||||
BookOpen,
|
BookOpen,
|
||||||
Check,
|
Check,
|
||||||
|
|
@ -11,7 +12,9 @@ import {
|
||||||
PenLine,
|
PenLine,
|
||||||
Search,
|
Search,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
|
import { searchSpacesAtom } from "@/atoms/search-spaces/search-space-query.atoms";
|
||||||
import {
|
import {
|
||||||
Command,
|
Command,
|
||||||
CommandEmpty,
|
CommandEmpty,
|
||||||
|
|
@ -35,6 +38,8 @@ const ICONS: Record<string, React.ReactNode> = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function QuickAskPage() {
|
export default function QuickAskPage() {
|
||||||
|
const router = useRouter();
|
||||||
|
const { data: searchSpaces = [] } = useAtomValue(searchSpacesAtom);
|
||||||
const [clipboardText, setClipboardText] = useState("");
|
const [clipboardText, setClipboardText] = useState("");
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -43,21 +48,24 @@ export default function QuickAskPage() {
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const navigateToChat = (prompt: string, mode: string) => {
|
||||||
|
if (!searchSpaces.length) return;
|
||||||
|
const spaceId = searchSpaces[0].id;
|
||||||
|
const encoded = encodeURIComponent(prompt);
|
||||||
|
router.push(`/dashboard/${spaceId}/new-chat?quickAskPrompt=${encoded}&quickAskMode=${mode}`);
|
||||||
|
};
|
||||||
|
|
||||||
const handleAction = (actionId: string) => {
|
const handleAction = (actionId: string) => {
|
||||||
const action = DEFAULT_ACTIONS.find((a) => a.id === actionId);
|
const action = DEFAULT_ACTIONS.find((a) => a.id === actionId);
|
||||||
if (!action || !clipboardText) return;
|
if (!action || !clipboardText) return;
|
||||||
|
|
||||||
const prompt = action.prompt.replace("{selection}", clipboardText);
|
const prompt = action.prompt.replace("{selection}", clipboardText);
|
||||||
const encoded = encodeURIComponent(prompt);
|
navigateToChat(prompt, action.mode);
|
||||||
const mode = action.mode;
|
|
||||||
|
|
||||||
window.location.href = `/dashboard?quickAskPrompt=${encoded}&quickAskMode=${mode}`;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleAskAnything = () => {
|
const handleAskAnything = () => {
|
||||||
if (!clipboardText) return;
|
if (!clipboardText) return;
|
||||||
const encoded = encodeURIComponent(clipboardText);
|
navigateToChat(clipboardText, "explore");
|
||||||
window.location.href = `/dashboard?quickAskPrompt=${encoded}&quickAskMode=explore`;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const transformActions = DEFAULT_ACTIONS.filter((a) => a.group === "transform");
|
const transformActions = DEFAULT_ACTIONS.filter((a) => a.group === "transform");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue