Content update
This commit is contained in:
parent
608dfbebc0
commit
5191157684
@ -542,6 +542,11 @@ const App = () => {
|
|||||||
if (prev <= 1) {
|
if (prev <= 1) {
|
||||||
clearInterval(timerRef.current);
|
clearInterval(timerRef.current);
|
||||||
timerRef.current = null;
|
timerRef.current = null;
|
||||||
|
if (isScrolledToBottom()) {
|
||||||
|
setTimeout(() => {
|
||||||
|
scrollToBottom();
|
||||||
|
}, 50)
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return prev - 1;
|
return prev - 1;
|
||||||
@ -567,8 +572,8 @@ const App = () => {
|
|||||||
// Height of the visible window
|
// Height of the visible window
|
||||||
const clientHeight = document.documentElement.clientHeight;
|
const clientHeight = document.documentElement.clientHeight;
|
||||||
|
|
||||||
// If we're at the bottom (allowing a small buffer of 5px)
|
// If we're at the bottom (allowing a small buffer of 16px)
|
||||||
return scrollTop + clientHeight >= scrollHeight - 5;
|
return scrollTop + clientHeight >= scrollHeight - 16;
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const scrollToBottom = useCallback(() => {
|
const scrollToBottom = useCallback(() => {
|
||||||
@ -971,7 +976,7 @@ const App = () => {
|
|||||||
|
|
||||||
const userMessage = [{ role: 'user', content: query }];
|
const userMessage = [{ role: 'user', content: query }];
|
||||||
|
|
||||||
let scrolledToBottom = isScrolledToBottom();
|
let scrolledToBottom;
|
||||||
|
|
||||||
// Add user message to conversation
|
// Add user message to conversation
|
||||||
const newConversation: MessageList = [
|
const newConversation: MessageList = [
|
||||||
@ -983,9 +988,6 @@ const App = () => {
|
|||||||
|
|
||||||
// Clear input
|
// Clear input
|
||||||
setQuery('');
|
setQuery('');
|
||||||
// setTimeout(() => {
|
|
||||||
// document.getElementById("QueryIput")?.focus();
|
|
||||||
// }, 1000);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
scrolledToBottom = isScrolledToBottom();
|
scrolledToBottom = isScrolledToBottom();
|
||||||
@ -999,7 +1001,7 @@ const App = () => {
|
|||||||
{ role: 'assistant', content: 'Processing request...', id: processingId, isProcessing: true }
|
{ role: 'assistant', content: 'Processing request...', id: processingId, isProcessing: true }
|
||||||
]);
|
]);
|
||||||
if (scrolledToBottom) {
|
if (scrolledToBottom) {
|
||||||
setTimeout(() => { scrollToBottom() }, 0);
|
setTimeout(() => { scrollToBottom() }, 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make the fetch request with proper headers
|
// Make the fetch request with proper headers
|
||||||
@ -1020,7 +1022,7 @@ const App = () => {
|
|||||||
setSnack(`Query sent. Response estimated in ${estimate}s.`, "info");
|
setSnack(`Query sent. Response estimated in ${estimate}s.`, "info");
|
||||||
startCountdown(Math.round(estimate));
|
startCountdown(Math.round(estimate));
|
||||||
if (scrolledToBottom) {
|
if (scrolledToBottom) {
|
||||||
setTimeout(() => { scrollToBottom() }, 0);
|
setTimeout(() => { scrollToBottom() }, 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
@ -1064,7 +1066,7 @@ const App = () => {
|
|||||||
: msg
|
: msg
|
||||||
));
|
));
|
||||||
if (scrolledToBottom) {
|
if (scrolledToBottom) {
|
||||||
setTimeout(() => { scrollToBottom() }, 0);
|
setTimeout(() => { scrollToBottom() }, 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a small delay to ensure React has time to update the UI
|
// Add a small delay to ensure React has time to update the UI
|
||||||
@ -1084,7 +1086,7 @@ const App = () => {
|
|||||||
setLastPromptTPS(promptTPS ? promptTPS : 35);
|
setLastPromptTPS(promptTPS ? promptTPS : 35);
|
||||||
updateContextStatus();
|
updateContextStatus();
|
||||||
if (scrolledToBottom) {
|
if (scrolledToBottom) {
|
||||||
setTimeout(() => { scrollToBottom() }, 0);
|
setTimeout(() => { scrollToBottom() }, 50);
|
||||||
}
|
}
|
||||||
} else if (update.status === 'error') {
|
} else if (update.status === 'error') {
|
||||||
// Show error
|
// Show error
|
||||||
@ -1094,7 +1096,7 @@ const App = () => {
|
|||||||
{ role: 'assistant', type: 'error', content: update.message }
|
{ role: 'assistant', type: 'error', content: update.message }
|
||||||
]);
|
]);
|
||||||
if (scrolledToBottom) {
|
if (scrolledToBottom) {
|
||||||
setTimeout(() => { scrollToBottom() }, 0);
|
setTimeout(() => { scrollToBottom() }, 50);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -1116,7 +1118,7 @@ const App = () => {
|
|||||||
update.message
|
update.message
|
||||||
]);
|
]);
|
||||||
if (scrolledToBottom) {
|
if (scrolledToBottom) {
|
||||||
setTimeout(() => { scrollToBottom() }, 0);
|
setTimeout(() => { scrollToBottom() }, 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -1124,8 +1126,12 @@ const App = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scrolledToBottom = isScrolledToBottom();
|
||||||
stopCountdown();
|
stopCountdown();
|
||||||
setProcessing(false);
|
setProcessing(false);
|
||||||
|
if (scrolledToBottom) {
|
||||||
|
setTimeout(() => { scrollToBottom() }, 50);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Fetch error:', error);
|
console.error('Fetch error:', error);
|
||||||
setSnack("Unable to process query", "error");
|
setSnack("Unable to process query", "error");
|
||||||
@ -1137,7 +1143,7 @@ const App = () => {
|
|||||||
setProcessing(false);
|
setProcessing(false);
|
||||||
stopCountdown();
|
stopCountdown();
|
||||||
if (scrolledToBottom) {
|
if (scrolledToBottom) {
|
||||||
setTimeout(() => { scrollToBottom() }, 0);
|
setTimeout(() => { scrollToBottom() }, 50);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user