fix(chat): keep composer fixed while messages overscroll
parent
63ef76dd80
commit
4afda18ec1
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
</t-tooltip>
|
||||
</div>
|
||||
</div>
|
||||
<div class="chat_thread" :style="{ '--chat-composer-height': `${composerHeight}px` }">
|
||||
<div class="chat_thread" :style="{ '--chat-composer-height': `${composerHeight}px`, '--chat-scrollbar-gutter': `${scrollbarGutter}px` }">
|
||||
<div ref="scrollContainer" class="chat_scroll_box" @scroll="handleScroll">
|
||||
<div class="chat_scroll_content">
|
||||
<div class="msg_list" :class="{ 'is-embedded': embeddedMode }">
|
||||
|
|
@ -149,26 +149,26 @@
|
|||
<span class="chat-global-wait__spinner" aria-hidden="true"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div ref="composerElement" class="chat_composer">
|
||||
<div class="input-container" :class="{ 'is-embedded': embeddedMode }">
|
||||
<transition name="scroll-btn-fade">
|
||||
<div v-show="userHasScrolledUp" class="scroll-to-bottom-btn" @click="onClickScrollToBottom">
|
||||
<t-icon name="chevron-down" size="18px" />
|
||||
</div>
|
||||
</transition>
|
||||
<InputField ref="inputFieldRef" :auto-focus="focusComposerOnMount" :compact="!embeddedMode"
|
||||
@send-msg="(query, modelId, mentionedItems, imageFiles, attachmentFiles, options) => sendMsg(query, modelId, mentionedItems, imageFiles, attachmentFiles, options)"
|
||||
@steer-msg="(query, mentionedItems, delivery) => handleSteerMsg(query, mentionedItems, delivery)"
|
||||
@promote-steer="handlePromoteSteer"
|
||||
@remove-steer="handleRemoveSteer"
|
||||
@retry-steer="handleRetrySteer"
|
||||
@stop-generation="handleStopGeneration"
|
||||
@stop-confirmed="handleStopConfirmed"
|
||||
@stop-failed="handleStopFailed" :isReplying="isReplying" :composer-locked="composerLocked" :sessionId="session_id"
|
||||
:assistantMessageId="currentAssistantMessageId" :embeddedMode="embeddedMode"
|
||||
:queuedSteers="steerQueue.filter(item => item.delivery === 'after')" :canSteer="isAgentStreamSession()"></InputField>
|
||||
</div>
|
||||
</div>
|
||||
<div ref="composerElement" class="chat_composer">
|
||||
<div class="input-container" :class="{ 'is-embedded': embeddedMode }">
|
||||
<transition name="scroll-btn-fade">
|
||||
<div v-show="userHasScrolledUp" class="scroll-to-bottom-btn" @click="onClickScrollToBottom">
|
||||
<t-icon name="chevron-down" size="18px" />
|
||||
</div>
|
||||
</div>
|
||||
</transition>
|
||||
<InputField ref="inputFieldRef" :auto-focus="focusComposerOnMount" :compact="!embeddedMode"
|
||||
@send-msg="(query, modelId, mentionedItems, imageFiles, attachmentFiles, options) => sendMsg(query, modelId, mentionedItems, imageFiles, attachmentFiles, options)"
|
||||
@steer-msg="(query, mentionedItems, delivery) => handleSteerMsg(query, mentionedItems, delivery)"
|
||||
@promote-steer="handlePromoteSteer"
|
||||
@remove-steer="handleRemoveSteer"
|
||||
@retry-steer="handleRetrySteer"
|
||||
@stop-generation="handleStopGeneration"
|
||||
@stop-confirmed="handleStopConfirmed"
|
||||
@stop-failed="handleStopFailed" :isReplying="isReplying" :composer-locked="composerLocked" :sessionId="session_id"
|
||||
:assistantMessageId="currentAssistantMessageId" :embeddedMode="embeddedMode"
|
||||
:queuedSteers="steerQueue.filter(item => item.delivery === 'after')" :canSteer="isAgentStreamSession()"></InputField>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="!embeddedMode" class="chat_overlays">
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue