SimpleChat:JS: Try ensure the last entry in chat is visible
Needed because now only the chat div is scrollable and not the full page. In last commit the chat div size was fixed to 75% vertical height, so the full page no longer scrolls, so the old bring user-input element to view wont work, instead now the last element in the chat div should be brought into view.
This commit is contained in:
parent
a1a2f36a45
commit
a944ce7cbe
1 changed files with 5 additions and 2 deletions
|
@ -45,11 +45,16 @@ class SimpleChat {
|
||||||
if (bClear) {
|
if (bClear) {
|
||||||
div.replaceChildren();
|
div.replaceChildren();
|
||||||
}
|
}
|
||||||
|
let last = undefined;
|
||||||
for(const x of this.xchat) {
|
for(const x of this.xchat) {
|
||||||
let entry = document.createElement("p");
|
let entry = document.createElement("p");
|
||||||
entry.className = `role-${x.role}`;
|
entry.className = `role-${x.role}`;
|
||||||
entry.innerText = `${x.role}: ${x.content}`;
|
entry.innerText = `${x.role}: ${x.content}`;
|
||||||
div.appendChild(entry);
|
div.appendChild(entry);
|
||||||
|
last = entry;
|
||||||
|
}
|
||||||
|
if (last !== undefined) {
|
||||||
|
last.scrollIntoView(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +144,6 @@ async function handle_submit(inputSystem, inputUser, divChat, apiEP) {
|
||||||
theBody = gChat.request_prompt_jsonstr();
|
theBody = gChat.request_prompt_jsonstr();
|
||||||
}
|
}
|
||||||
|
|
||||||
inputUser.scrollIntoView(true);
|
|
||||||
inputUser.value = "working...";
|
inputUser.value = "working...";
|
||||||
inputUser.disabled = true;
|
inputUser.disabled = true;
|
||||||
console.debug(`DBUG:HandleSubmit:${theUrl}:ReqBody:${theBody}`);
|
console.debug(`DBUG:HandleSubmit:${theUrl}:ReqBody:${theBody}`);
|
||||||
|
@ -174,7 +178,6 @@ async function handle_submit(inputSystem, inputUser, divChat, apiEP) {
|
||||||
if ((apiEP == ApiEP.Completion) && (gbCompletionFreshChatAlways)) {
|
if ((apiEP == ApiEP.Completion) && (gbCompletionFreshChatAlways)) {
|
||||||
gChat.xchat.length = 0;
|
gChat.xchat.length = 0;
|
||||||
}
|
}
|
||||||
inputUser.scrollIntoView(true);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue