refac: suggestion prompts

This commit is contained in:
Timothy Jaeryang Baek
2025-07-04 23:40:31 +04:00
parent db0d2ae6d4
commit 198b89faa5
7 changed files with 32 additions and 64 deletions
+3 -38
View File
@@ -43,45 +43,12 @@
export let codeInterpreterEnabled = false;
export let webSearchEnabled = false;
export let onSelect = (e) => {};
export let toolServers = [];
let models = [];
const selectSuggestionPrompt = async (p) => {
let text = p;
if (p.includes('{{CLIPBOARD}}')) {
const clipboardText = await navigator.clipboard.readText().catch((err) => {
toast.error($i18n.t('Failed to read clipboard contents'));
return '{{CLIPBOARD}}';
});
text = p.replaceAll('{{CLIPBOARD}}', clipboardText);
console.log('Clipboard text:', clipboardText, text);
}
prompt = text;
console.log(prompt);
await tick();
const chatInputContainerElement = document.getElementById('chat-input-container');
const chatInputElement = document.getElementById('chat-input');
if (chatInputContainerElement) {
chatInputContainerElement.scrollTop = chatInputContainerElement.scrollHeight;
}
await tick();
if (chatInputElement) {
chatInputElement.focus();
chatInputElement.dispatchEvent(new Event('input'));
}
await tick();
};
let selectedModelIdx = 0;
$: if (selectedModels.length > 0) {
@@ -255,9 +222,7 @@
$config?.default_prompt_suggestions ??
[]}
inputValue={prompt}
on:select={(e) => {
selectSuggestionPrompt(e.detail);
}}
{onSelect}
/>
</div>
</div>