From 4afda18ec1ae3a166ab75cbb9b0c270f155929d0 Mon Sep 17 00:00:00 2001 From: wizardchen Date: Tue, 22 Sep 2026 23:23:13 +0800 Subject: [PATCH] fix(chat): keep composer fixed while messages overscroll --- .../src/composables/useChatQuestionMinimap.ts | 2 +- frontend/src/views/chat/index.vue | 77 +++++++++++-------- 2 files changed, 45 insertions(+), 34 deletions(-) diff --git a/frontend/src/composables/useChatQuestionMinimap.ts b/frontend/src/composables/useChatQuestionMinimap.ts index dba15da3..551d9402 100644 --- a/frontend/src/composables/useChatQuestionMinimap.ts +++ b/frontend/src/composables/useChatQuestionMinimap.ts @@ -116,7 +116,7 @@ export function useChatQuestionMinimap(options: { ticks.value = mapQuestionTicks(measured, trackHeight.value) viewport.value = viewportBand(el.scrollTop, el.clientHeight, el.scrollHeight, trackHeight.value) activeId.value = activeQuestionId(measured, el.scrollTop) - // The sticky composer is inside the scroll viewport but obscures its bottom. + // The composer overlays the bottom of the message scroll viewport. const bottomInset = parseFloat(containerStyle.scrollPaddingBottom) || 0 visibleIds.value = visibleMessageIds(measured, el.scrollTop, el.clientHeight, bottomInset) anchoredIds.value = new Set(measured.map((item) => item.id)) diff --git a/frontend/src/views/chat/index.vue b/frontend/src/views/chat/index.vue index 9fdadd4a..6d71a099 100644 --- a/frontend/src/views/chat/index.vue +++ b/frontend/src/views/chat/index.vue @@ -22,7 +22,7 @@ -
+
@@ -149,26 +149,26 @@
-
-
- -
- -
-
- +
+
+
+
+ +
+
-
+ +
@@ -585,14 +585,19 @@ let fullContent = ref('') const scrollContainer = ref(null) const composerElement = ref(null) const composerHeight = ref(0) -// Keep floating previews above the sticky composer, including when its controls -// wrap after a drawer opens or the user adds multiple lines/attachments. -watch(composerElement, (element, _, onCleanup) => { - if (!element) return - const measure = () => { composerHeight.value = element.offsetHeight } +const scrollbarGutter = ref(0) +// Reserve space for the independent composer and keep it aligned with the +// message column when drawers, multiline input or attachments change its size. +watch([composerElement, scrollContainer], ([element, scroller], _, onCleanup) => { + if (!element || !scroller) return + const measure = () => { + composerHeight.value = element.offsetHeight + scrollbarGutter.value = scroller.offsetWidth - scroller.clientWidth + } measure() const observer = new ResizeObserver(measure) observer.observe(element) + observer.observe(scroller) onCleanup(() => observer.disconnect()) }, { flush: 'post' }) const userHasScrolledUp = ref(false) @@ -1886,9 +1891,8 @@ onBeforeRouteUpdate((to, from, next) => { padding: 8px 0 0; box-sizing: border-box; overflow-y: auto; - // Disable boundary bounce as well as scroll chaining: the sticky composer - // shares this viewport and otherwise moves with its rubber-band animation. - overscroll-behavior-y: none; + // Keep native message bounce without chaining scroll to the outer page. + overscroll-behavior-y: contain; scroll-padding-bottom: var(--chat-composer-height, 0px); scrollbar-gutter: stable; scrollbar-width: thin; @@ -1918,20 +1922,27 @@ onBeforeRouteUpdate((to, from, next) => { } } -// One scroll viewport spans the messages and composer, so the scrollbar reaches -// the bottom of the chat column. The composer stays in flow to reserve its own -// height, and sticks to the bottom while reading earlier messages. +// Keep the full-height message scrollbar and reserve space below the last +// message for the composer, which sits outside the bouncing scroll viewport. .chat_scroll_content { display: flex; flex-direction: column; min-height: 100%; + + // Use an in-flow spacer so the content ResizeObserver also detects composer + // height changes and keeps the last message visible when following replies. + &::after { + content: ''; + flex: 0 0 var(--chat-composer-height, 0px); + } } .chat_composer { - position: sticky; + position: absolute; bottom: 0; + left: 0; + right: var(--chat-scrollbar-gutter, 0px); z-index: 12; - flex-shrink: 0; padding: 16px 0 max(8px, env(safe-area-inset-bottom)); background: var(--td-bg-color-container); }