diff --git a/client/main.tsx b/client/main.tsx index b8239bd..5639b3c 100644 --- a/client/main.tsx +++ b/client/main.tsx @@ -71,6 +71,9 @@ function conversationUI(id: string) { if (typeof event.data !== "string") return; const message = JSON.parse(event.data); + const scrolledToBottom = + chatlog.scrollTop + 16 >= chatlog.scrollHeight - chatlog.clientHeight; + if ("i" in message) { window.history.replaceState(null, "", "#" + message.i); id = message.i; @@ -103,6 +106,8 @@ function conversationUI(id: string) { inFlightMessages.delete(message.r); } } + + if (scrolledToBottom) chatlog.scrollTop = chatlog.scrollHeight - chatlog.clientHeight; }); const form = ( @@ -121,7 +126,7 @@ function conversationUI(id: string) { return (
{header} -
{chatlog}
+ {chatlog} {form}
); diff --git a/client/response.tsx b/client/response.tsx index f0733e2..e6ba06a 100644 --- a/client/response.tsx +++ b/client/response.tsx @@ -77,6 +77,11 @@ export class ChatResponse { this.currentLine.appendData(token); } } + + if (this.thinkingContext) { + this.thinkingContext.scrollTop = + this.thinkingContext.scrollHeight - this.thinkingContext.clientHeight; + } } finalize() { diff --git a/client/web/css/styles.css b/client/web/css/styles.css index 1ecbe04..c8faec3 100644 --- a/client/web/css/styles.css +++ b/client/web/css/styles.css @@ -66,18 +66,12 @@ main, } } -.chatlog-wrapper { - flex: 1; - - display: flex; - flex-direction: column-reverse; - overflow-y: scroll; -} - .chatlog { flex: 1; + display: flex; flex-direction: column; + overflow-y: scroll; article { white-space: preserve;