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