fix(webui): hide actions until turn end

This commit is contained in:
Zhou authored and Xubin Ren committed 2026-08-16 00:14:42 +08:00
1 parent 5e84055dbb
commit 48126f049d
5 files changed
+213 -8

No files matched your search

+34 -1
View File
@@ -91,6 +91,9 @@ export function ThreadMessages({
&& pendingTurn !== null
&& !pendingTurn.hasVisibleOutput
) ? pendingTurn : null;
const currentTurnStartIndex = isStreaming
? activeTurnStartIndex(units, activeTurnId)
: units.length;
const unitKeys = useMemo(() => unitKeysForDisplay(units), [units]);
let nextUserIndex = hiddenUserMessageCount;
@@ -140,7 +143,15 @@ export function ThreadMessages({
userPromptId={userPromptId}
hasBodyBelow={hasBodyBelow}
deferOffscreenRender={deferOffscreenRender}
isTurnStreaming={liveActivityClusterIndices.has(index)}
isTurnStreaming={
unit.type === "activity"
? liveActivityClusterIndices.has(index)
: isStreaming && (
unit.message.turnId
? unit.message.turnId === activeTurnId
: index > currentTurnStartIndex
)
}
forkIndex={forkIndex}
showForkBoundary={index === forkBoundaryAfterUnitIndex}
forkBoundaryLabel={t("thread.forkedFromHistory")}
@@ -280,6 +291,7 @@ const ThreadDisplayUnit = memo(function ThreadDisplayUnit({
) : (
<MessageBubble
message={unit.message}
isTurnStreaming={isTurnStreaming}
temporary={temporary}
cliApps={cliApps}
mcpPresets={mcpPresets}
@@ -317,6 +329,27 @@ function threadDisplayUnitPropsEqual(
);
}
function activeTurnStartIndex(units: DisplayUnit[], activeTurnId: string | null): number {
if (activeTurnId) {
const index = units.findIndex((unit) => (
unit.type === "message"
&& unit.message.role === "user"
&& unit.message.deliveryStatus !== "failed"
&& unit.message.turnId === activeTurnId
));
if (index >= 0) return index;
}
for (let i = units.length - 1; i >= 0; i -= 1) {
const unit = units[i];
if (
unit.type === "message"
&& unit.message.role === "user"
&& unit.message.deliveryStatus !== "failed"
) return i;
}
return -1;
}
function displayUnitsEqual(previous: DisplayUnit, next: DisplayUnit): boolean {
if (previous.type !== next.type) return false;
if (previous.type === "message" && next.type === "message") {