Skip to content

Commit 4aeec44

Browse files
authored
Merge pull request stackblitz-labs#669 from thecodacus/prompt-url-params
feat(url-prompt) added prompt url params
2 parents 9b91d56 + 07e41f7 commit 4aeec44

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

app/commit.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "commit": "49b02dd885919e24a201f07b1a7b0fd0371b4f85" , "version": "0.0.1" }
1+
{ "commit": "e3bdd6944be8e4b4a6bb6c81f569fb3d5f444942" }

app/components/chat/Chat.client.tsx

+20
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import Cookies from 'js-cookie';
2020
import { debounce } from '~/utils/debounce';
2121
import { useSettings } from '~/lib/hooks/useSettings';
2222
import type { ProviderInfo } from '~/types/model';
23+
import { useSearchParams } from '@remix-run/react';
2324

2425
const toastAnimation = cssTransition({
2526
enter: 'animated fadeInRight',
@@ -92,6 +93,7 @@ export const ChatImpl = memo(
9293
const [chatStarted, setChatStarted] = useState(initialMessages.length > 0);
9394
const [uploadedFiles, setUploadedFiles] = useState<File[]>([]); // Move here
9495
const [imageDataList, setImageDataList] = useState<string[]>([]); // Move here
96+
const [searchParams, setSearchParams] = useSearchParams();
9597
const files = useStore(workbenchStore.files);
9698
const { activeProviders, promptId } = useSettings();
9799

@@ -138,6 +140,24 @@ export const ChatImpl = memo(
138140
initialMessages,
139141
initialInput: Cookies.get(PROMPT_COOKIE_KEY) || '',
140142
});
143+
useEffect(() => {
144+
const prompt = searchParams.get('prompt');
145+
console.log(prompt, searchParams, model, provider);
146+
147+
if (prompt) {
148+
setSearchParams({});
149+
runAnimation();
150+
append({
151+
role: 'user',
152+
content: [
153+
{
154+
type: 'text',
155+
text: `[Model: ${model}]\n\n[Provider: ${provider.name}]\n\n${prompt}`,
156+
},
157+
] as any, // Type assertion to bypass compiler check
158+
});
159+
}
160+
}, [model, provider, searchParams]);
141161

142162
const { enhancingPrompt, promptEnhanced, enhancePrompt, resetEnhancer } = usePromptEnhancer();
143163
const { parsedMessages, parseMessages } = useMessageParser();

0 commit comments

Comments
 (0)