fix(web): 无用户行钉顶、闲置不上留白,并修会话列表 tsc 两错
This commit is contained in:
@@ -76,9 +76,26 @@ export function applyFollowBottom(
|
||||
element.scrollTop = element.scrollHeight;
|
||||
}
|
||||
|
||||
export function lastTurnTail(container: HTMLElement): HTMLElement | null {
|
||||
return (container.querySelector(".message-list > :last-child .message-assistant")
|
||||
?? container.querySelector(".message-assistant:last-of-type")
|
||||
?? container.querySelector(".message-user:last-of-type")) as HTMLElement | null;
|
||||
}
|
||||
|
||||
export function turnHeadHeightForSpacer(head: HTMLElement | null, tail: HTMLElement | null): number {
|
||||
if (!head) return 0;
|
||||
// The last assistant carries the min-height spacer. Measuring it as the turn
|
||||
// head feeds the spacer back into itself (BUG-931).
|
||||
if (tail && head === tail) return 0;
|
||||
return head.offsetHeight;
|
||||
}
|
||||
|
||||
export function applyTurnSpacer(container: HTMLElement, head: HTMLElement | null): void {
|
||||
container.style.setProperty("--conversation-viewport", `${container.clientHeight}px`);
|
||||
container.style.setProperty("--latest-turn-head-height", `${head?.offsetHeight ?? 0}px`);
|
||||
container.style.setProperty(
|
||||
"--latest-turn-head-height",
|
||||
`${turnHeadHeightForSpacer(head, lastTurnTail(container))}px`,
|
||||
);
|
||||
}
|
||||
|
||||
export function clearTurnSpacer(container: HTMLElement): void {
|
||||
@@ -86,12 +103,6 @@ export function clearTurnSpacer(container: HTMLElement): void {
|
||||
container.style.removeProperty("--latest-turn-head-height");
|
||||
}
|
||||
|
||||
export function lastTurnTail(container: HTMLElement): HTMLElement | null {
|
||||
return (container.querySelector(".message-list > :last-child .message-assistant")
|
||||
?? container.querySelector(".message-assistant:last-of-type")
|
||||
?? container.querySelector(".message-user:last-of-type")) as HTMLElement | null;
|
||||
}
|
||||
|
||||
export function turnTailOverflow(container: HTMLElement): number {
|
||||
const last = lastTurnTail(container);
|
||||
if (!last) return conversationDistanceFromBottom(container);
|
||||
@@ -198,8 +209,8 @@ export function useConversationScrollAnchor(
|
||||
}
|
||||
if (anchoredRef.current) {
|
||||
element.scrollTop = element.scrollHeight;
|
||||
} else {
|
||||
applyTurnSpacer(element, pinnedHeadRef.current ?? resolveTurnHead(element));
|
||||
} else if (pinnedHeadRef.current) {
|
||||
applyTurnSpacer(element, pinnedHeadRef.current);
|
||||
}
|
||||
setLatestBelowFold(latestContentBelowFold(turnTailOverflow(element)));
|
||||
};
|
||||
@@ -240,7 +251,9 @@ export function useConversationScrollAnchor(
|
||||
const element = container.current;
|
||||
holdUnpin.current = false;
|
||||
shouldLand.current = false;
|
||||
pinnedHeadRef.current = null;
|
||||
if (element) {
|
||||
clearTurnSpacer(element);
|
||||
const reduceMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
||||
element.scrollTo({ top: element.scrollHeight, behavior: reduceMotion ? "auto" : "smooth" });
|
||||
setLatestBelowFold(false);
|
||||
|
||||
@@ -27,7 +27,7 @@ export function toSidebarSessionRow(
|
||||
): SidebarSession {
|
||||
return {
|
||||
id: session.id,
|
||||
title: sessionSidebarTitle(session, library),
|
||||
title: sessionSidebarTitle(session),
|
||||
subtitle: sessionSidebarSubtitle(session, library) || null,
|
||||
pinned: session.pinned,
|
||||
archived: Boolean(session.archivedAt),
|
||||
|
||||
Reference in New Issue
Block a user