fix(web): 无用户行钉顶、闲置不上留白,并修会话列表 tsc 两错
Independent Staging Quality Gate / validate (push) Failing after 6m27s
Independent Staging Quality Gate / publish (push) Skipped

This commit is contained in:
jesse-ux
2026-09-17 22:25:53 +08:00
parent b5e16b96f4
commit cc1a89802e
8 changed files with 135 additions and 16 deletions
@@ -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);
+1 -1
View File
@@ -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),