mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-25 19:15:18 +02:00
auto-submit quick-ask prompt from URL param
This commit is contained in:
parent
06f02fba0a
commit
6c59b3ee95
1 changed files with 23 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ import {
|
||||||
type AppendMessage,
|
type AppendMessage,
|
||||||
AssistantRuntimeProvider,
|
AssistantRuntimeProvider,
|
||||||
type ThreadMessageLike,
|
type ThreadMessageLike,
|
||||||
|
useAui,
|
||||||
useExternalStoreRuntime,
|
useExternalStoreRuntime,
|
||||||
} from "@assistant-ui/react";
|
} from "@assistant-ui/react";
|
||||||
import { useQueryClient } from "@tanstack/react-query";
|
import { useQueryClient } from "@tanstack/react-query";
|
||||||
|
|
@ -158,6 +159,27 @@ const TOOLS_WITH_UI = new Set([
|
||||||
// "write_todos", // Disabled for now
|
// "write_todos", // Disabled for now
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
function QuickAskAutoSubmit() {
|
||||||
|
const searchParams = useSearchParams();
|
||||||
|
const aui = useAui();
|
||||||
|
const submittedRef = useRef(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!window.electronAPI || submittedRef.current) return;
|
||||||
|
|
||||||
|
const prompt = searchParams.get("quickAskPrompt");
|
||||||
|
if (!prompt) return;
|
||||||
|
|
||||||
|
submittedRef.current = true;
|
||||||
|
setTimeout(() => {
|
||||||
|
aui.composer().setText(prompt);
|
||||||
|
aui.composer().send();
|
||||||
|
}, 500);
|
||||||
|
}, [searchParams, aui]);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
export default function NewChatPage() {
|
export default function NewChatPage() {
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
@ -1587,6 +1609,7 @@ export default function NewChatPage() {
|
||||||
return (
|
return (
|
||||||
<AssistantRuntimeProvider runtime={runtime}>
|
<AssistantRuntimeProvider runtime={runtime}>
|
||||||
<ThinkingStepsDataUI />
|
<ThinkingStepsDataUI />
|
||||||
|
<QuickAskAutoSubmit />
|
||||||
<div key={searchSpaceId} className="flex h-[calc(100dvh-64px)] overflow-hidden">
|
<div key={searchSpaceId} className="flex h-[calc(100dvh-64px)] overflow-hidden">
|
||||||
<div className="flex-1 flex flex-col min-w-0 overflow-hidden">
|
<div className="flex-1 flex flex-col min-w-0 overflow-hidden">
|
||||||
<Thread />
|
<Thread />
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue