fix(webui): stabilize earlier-history loading and reclaim space (#6349)

* fix(webui): retain smoothly revealed history loading headers

* refactor(webui): simplify history loading feedback

* fix(webui): keep retained history headers clear of preceding text

* fix(webui): reclaim completed history loading space

* refactor(webui): group history projection handoff with navigation

* test(webui): synchronize history motion observations

* fix(webui): collapse history completion geometry handoff
This commit is contained in:
chengyongru authored and GitHub committed 2026-10-21 13:10:05 +08:00
1 parent 73a55e0b2f
commit 743c51e81f
24 files changed
+1658 -356

No files matched your search

+22 -8
View File
@@ -23,6 +23,8 @@ import type { CliAppInfo, McpPresetInfo, RetryStatus, SlashCommand, UIMessage }
interface ThreadMessagesProps {
messages: UIMessage[];
beforeMessages?: ReactNode;
beforeUnit?: { key: string; content: ReactNode };
topInset?: number;
afterUserMessage?: (message: UIMessage) => ReactNode;
afterMessages?: ReactNode;
temporary?: boolean;
@@ -81,6 +83,8 @@ export function assistantForkFlags(units: DisplayUnit[]): boolean[] {
export function ThreadMessages({
messages,
beforeMessages,
beforeUnit,
topInset = 0,
afterUserMessage,
afterMessages,
temporary = false,
@@ -174,6 +178,11 @@ export function ThreadMessages({
setOpenContextBlockKey((current) => open ? key : current === key ? null : current);
}, []);
let nextUserIndex = hiddenUserMessageCount;
const preludeIndex = Math.max(0, beforeUnit ? unitKeys.indexOf(beforeUnit.key) : 0);
const inset = topInset > 0 ? <div aria-hidden style={{ height: topInset }} /> : null;
const preludeInset = preludeIndex === 0 ? inset : null;
const renderPrelude = (prefix: ReactNode, marginTop?: string) => prefix || preludeInset || beforeMessages
? <div key="thread-prelude" className={cn("flow-root", marginTop)}>{prefix}{preludeInset}{beforeMessages}</div> : null;
return (
<div ref={messageListRef} className="flex w-full flex-col">
@@ -181,8 +190,10 @@ export function ThreadMessages({
containerRef={messageListRef}
onQuoteSelection={onQuoteSelection}
/>
{beforeMessages}
{units.map((unit, index) => {
{[
preludeIndex > 0 ? <Fragment key="top-inset">{inset}</Fragment> : null,
units.length === 0 ? renderPrelude(null) : null,
...units.flatMap((unit, index) => {
const next = units[index + 1];
const hasBodyBelow =
unit.type === "activity"
@@ -233,14 +244,17 @@ export function ThreadMessages({
&& unit.message.deliveryStatus !== "failed"
) nextUserIndex += 1;
return (
<Fragment key={unitKeys[index]}>
const prefix = beforeUnit?.key === unitKeys[index] ? beforeUnit.content : null;
const prelude = index === preludeIndex ? renderPrelude(prefix, marginTop) : null;
return [
prelude,
<Fragment key={`unit:${unitKeys[index]}`}>
<ThreadDisplayUnit
key={unitKeys[index]}
unitKey={unitKeys[index]}
unit={unit}
mobileActions={mobileActions}
marginTop={marginTop}
marginTop={prelude ? "" : marginTop}
userPromptId={userPromptId}
hasBodyBelow={hasBodyBelow}
suppressActivity={suppressActivity}
@@ -279,9 +293,9 @@ export function ThreadMessages({
{unit.type === "message" && unit.message.role === "user" ? (
afterUserMessage?.(unit.message)
) : null}
</Fragment>
);
})}
</Fragment>,
];
})]}
{afterMessages}
{pendingActivity ? (
<div className={cn("thread-message-row", units.length > 0 && "mt-5")}>