mirror of
https://github.com/open-webui/open-webui
synced 2025-03-03 19:07:21 +00:00
enh: preserve input
This commit is contained in:
parent
7a787efc4b
commit
6981e1e467
@ -131,10 +131,29 @@
|
||||
$: if (chatIdProp) {
|
||||
(async () => {
|
||||
console.log(chatIdProp);
|
||||
|
||||
prompt = '';
|
||||
files = [];
|
||||
selectedToolIds = [];
|
||||
webSearchEnabled = false;
|
||||
|
||||
loaded = false;
|
||||
|
||||
if (chatIdProp && (await loadChat())) {
|
||||
await tick();
|
||||
loaded = true;
|
||||
|
||||
if (localStorage.getItem(`chat-input-${chatIdProp}`)) {
|
||||
try {
|
||||
const input = JSON.parse(localStorage.getItem(`chat-input-${chatIdProp}`));
|
||||
|
||||
prompt = input.prompt;
|
||||
files = input.files;
|
||||
selectedToolIds = input.selectedToolIds;
|
||||
webSearchEnabled = input.webSearchEnabled;
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
window.setTimeout(() => scrollToBottom(), 0);
|
||||
const chatInput = document.getElementById('chat-input');
|
||||
chatInput?.focus();
|
||||
@ -390,6 +409,21 @@
|
||||
}
|
||||
}
|
||||
|
||||
if (localStorage.getItem(`chat-input-${chatIdProp}`)) {
|
||||
try {
|
||||
const input = JSON.parse(localStorage.getItem(`chat-input-${chatIdProp}`));
|
||||
prompt = input.prompt;
|
||||
files = input.files;
|
||||
selectedToolIds = input.selectedToolIds;
|
||||
webSearchEnabled = input.webSearchEnabled;
|
||||
} catch (e) {
|
||||
prompt = '';
|
||||
files = [];
|
||||
selectedToolIds = [];
|
||||
webSearchEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
showControls.subscribe(async (value) => {
|
||||
if (controlPane && !$mobile) {
|
||||
try {
|
||||
@ -2019,6 +2053,13 @@
|
||||
transparentBackground={$settings?.backgroundImageUrl ?? false}
|
||||
{stopResponse}
|
||||
{createMessagePair}
|
||||
onChange={(input) => {
|
||||
if (input.prompt) {
|
||||
localStorage.setItem(`chat-input-${$chatId}`, JSON.stringify(input));
|
||||
} else {
|
||||
localStorage.removeItem(`chat-input-${$chatId}`);
|
||||
}
|
||||
}}
|
||||
on:upload={async (e) => {
|
||||
const { type, data } = e.detail;
|
||||
|
||||
|
@ -43,6 +43,7 @@
|
||||
|
||||
export let transparentBackground = false;
|
||||
|
||||
export let onChange: Function = () => {};
|
||||
export let createMessagePair: Function;
|
||||
export let stopResponse: Function;
|
||||
|
||||
@ -62,6 +63,13 @@
|
||||
export let selectedToolIds = [];
|
||||
export let webSearchEnabled = false;
|
||||
|
||||
$: onChange({
|
||||
prompt,
|
||||
files,
|
||||
selectedToolIds,
|
||||
webSearchEnabled
|
||||
});
|
||||
|
||||
let loaded = false;
|
||||
let recording = false;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user