Skip to content

Your lightweight open-source personal agent.

refactor(webui): derive footer spacing from thread tail

chengyongru0f3cabb16d10
diff --git a/webui/src/components/MessageBubble.tsx b/webui/src/components/MessageBubble.tsx
index 979cff3b4..5220e09a8 100644
--- a/webui/src/components/MessageBubble.tsx
+++ b/webui/src/components/MessageBubble.tsx
@@ -66,8 +66,8 @@ interface MessageBubbleProps {
temporary?: boolean;
/** When false, hide this message's copy button. Default true. */
showCopyAction?: boolean;
- /** Whether this is the final assistant text slice before the next user turn. */
- isTerminalAssistantSlice?: boolean;
+ /** Whether this message is the final display unit in the thread. */
+ isThreadTail?: boolean;
cliApps?: CliAppInfo[];
mcpPresets?: McpPresetInfo[];
slashCommands?: SlashCommand[];
@@ -332,7 +332,7 @@ export function MessageBubble({
isTurnStreaming = false,
temporary = false,
showCopyAction = true,
- isTerminalAssistantSlice = true,
+ isThreadTail = true,
cliApps = [],
mcpPresets = [],
slashCommands = [],
@@ -486,7 +486,7 @@ export function MessageBubble({
? completedAt
: message.createdAt;
const assistantTimestampLabel =
- message.role === "assistant" && !message.isStreaming
+ message.role === "assistant" && !message.isStreaming && !isTurnStreaming
? formatMessageEndTime(assistantTimestamp)
: "";
const showCompletedAt =
@@ -494,8 +494,7 @@ export function MessageBubble({
&& (!empty || hasReasoning || media.length > 0);
const showAssistantTimestamp =
assistantTimestampLabel.length > 0
- && (!empty || hasReasoning || media.length > 0)
- && (!isTurnStreaming || isTerminalAssistantSlice);
+ && (!empty || hasReasoning || media.length > 0);
const assistantTimestampTitle = showAssistantTimestamp ? fmtDateTime(assistantTimestamp) : "";
const showAutomationTrigger = showAssistantTimestamp && automationSourceLabel.length > 0;
const showAssistantFooterRow =
@@ -505,7 +504,7 @@ export function MessageBubble({
&& (!empty || hasReasoning || media.length > 0);
const showAssistantFooterSlot =
hasAssistantFooterContent
- && (showAssistantFooterRow || isTerminalAssistantSlice);
+ && (showAssistantFooterRow || ((message.isStreaming || isTurnStreaming) && isThreadTail));
return (
<div className="w-full text-[15px]" style={{ lineHeight: "var(--cjk-line-height)" }}>
{hasReasoning ? (
diff --git a/webui/src/components/thread/ThreadMessages.tsx b/webui/src/components/thread/ThreadMessages.tsx
index 4f87039c3..18f337669 100644
--- a/webui/src/components/thread/ThreadMessages.tsx
+++ b/webui/src/components/thread/ThreadMessages.tsx
@@ -143,6 +143,14 @@ export function ThreadMessages({
unit.type === "message" && unit.message.role === "assistant" && forkFlags[index]
? nextUserIndex
: undefined;
+ const unitTurnStreaming = unit.type === "activity"
+ ? liveActivityClusterIndices.has(index)
+ : isStreaming && (
+ unit.message.turnId && activeTurnId !== null
+ ? unit.message.turnId === activeTurnId
+ : index > currentTurnStartIndex
+ );
+ const isThreadTail = index === units.length - 1;
if (
unit.type === "message"
&& unit.message.role === "user"
@@ -158,15 +166,8 @@ export function ThreadMessages({
userPromptId={userPromptId}
hasBodyBelow={hasBodyBelow}
deferOffscreenRender={deferOffscreenRender}
- isTurnStreaming={
- unit.type === "activity"
- ? liveActivityClusterIndices.has(index)
- : isStreaming && (
- unit.message.turnId && activeTurnId !== null
- ? unit.message.turnId === activeTurnId
- : index > currentTurnStartIndex
- )
- }
+ isTurnStreaming={unitTurnStreaming}
+ isThreadTail={isThreadTail}
retryStatus={
unit.type === "activity" && liveActivityClusterIndices.has(index)
? retryStatus
@@ -256,6 +257,7 @@ interface ThreadDisplayUnitProps {
hasBodyBelow: boolean;
deferOffscreenRender: boolean;
isTurnStreaming: boolean;
+ isThreadTail: boolean;
retryStatus: RetryStatus | null;
forkIndex?: number;
showForkBoundary: boolean;
@@ -278,6 +280,7 @@ const ThreadDisplayUnit = memo(function ThreadDisplayUnit({
hasBodyBelow,
deferOffscreenRender,
isTurnStreaming,
+ isThreadTail,
retryStatus,
forkIndex,
showForkBoundary,
@@ -343,8 +346,8 @@ const ThreadDisplayUnit = memo(function ThreadDisplayUnit({
<MessageBubble
message={unit.message}
isTurnStreaming={isTurnStreaming}
+ isThreadTail={isThreadTail}
temporary={temporary}
- isTerminalAssistantSlice={forkIndex !== undefined}
cliApps={cliApps}
mcpPresets={mcpPresets}
slashCommands={slashCommands}
@@ -369,6 +372,7 @@ function threadDisplayUnitPropsEqual(
&& previous.hasBodyBelow === next.hasBodyBelow
&& previous.deferOffscreenRender === next.deferOffscreenRender
&& previous.isTurnStreaming === next.isTurnStreaming
+ && previous.isThreadTail === next.isThreadTail
&& previous.retryStatus === next.retryStatus
&& previous.forkIndex === next.forkIndex
&& previous.showForkBoundary === next.showForkBoundary
diff --git a/webui/src/tests/message-bubble.test.tsx b/webui/src/tests/message-bubble.test.tsx
index 51574352c..d0e667b6f 100644
--- a/webui/src/tests/message-bubble.test.tsx
+++ b/webui/src/tests/message-bubble.test.tsx
@@ -868,7 +868,7 @@ describe("MessageBubble", () => {
expect(visibleFooter).toHaveClass("mt-2", "min-h-8", "opacity-100");
});
- it("omits hidden footer space for an intermediate assistant answer", () => {
+ it("omits footer space when an active answer is no longer the tail", () => {
const message: UIMessage = {
id: "a-intermediate",
role: "assistant",
@@ -880,7 +880,7 @@ describe("MessageBubble", () => {
<MessageBubble
message={message}
isTurnStreaming
- isTerminalAssistantSlice={false}
+ isThreadTail={false}
/>,
);
diff --git a/webui/src/tests/thread-messages.test.tsx b/webui/src/tests/thread-messages.test.tsx
index fb334a2db..262655906 100644
--- a/webui/src/tests/thread-messages.test.tsx
+++ b/webui/src/tests/thread-messages.test.tsx
@@ -1532,7 +1532,7 @@ describe("ThreadMessages", () => {
.closest<HTMLElement>("[data-thread-display-unit]")!;
expect(firstAnswer.querySelector("[data-assistant-footer]")).not.toBeInTheDocument();
expect(finalAnswer.querySelector("[data-assistant-footer]"))
- .toHaveAttribute("data-state", "visible");
+ .toHaveAttribute("data-state", "reserved");
expect(container.querySelectorAll('[data-assistant-footer] [aria-label="Copy"]')).toHaveLength(1);
expect(container.querySelectorAll('[data-assistant-footer] [aria-label="Fork"]')).toHaveLength(1);