mirror of
https://github.com/ggml-org/llama.cpp.git
synced 2026-09-17 20:31:47 +02:00
ui : measure assistant layout only for the last message
Every assistant message ran getComputedStyle, getBoundingClientRect and a ResizeObserver over the previous user bubble at mount, even off-screen ones, forcing a layout pass per message while a long conversation renders. The measured vars only feed the :last-child min-height rule, so gate the effect on isLastAssistantMessage; one measurement and one observer remain, and the effect re-runs when the last message changes. Assisted-by: pi:zai-org/GLM-5.3
This commit is contained in:
+4
-1
@@ -82,8 +82,11 @@
|
||||
let lastUserMessageHeight = $state(0);
|
||||
let assistantMarginTop = $state(0);
|
||||
|
||||
// The measured CSS vars feed the :last-child min-height rule only, so only
|
||||
// the last assistant message needs them. Reading isLastAssistantMessage
|
||||
// here also re-runs the effect when this message stops being the last.
|
||||
$effect(() => {
|
||||
if (!assistantEl) return;
|
||||
if (!assistantEl || !isLastAssistantMessage) return;
|
||||
|
||||
assistantMarginTop = Math.round(parseFloat(getComputedStyle(assistantEl).marginTop));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user