fix(frontend): suppressing event display in the absence of user messages (#10955)

This commit is contained in:
Hiep Le 2025-09-15 20:56:16 +07:00 committed by GitHub
parent ab893f93f0
commit e74bbd81d1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 5 deletions

View File

@ -25,7 +25,10 @@ import { displayErrorToast } from "#/utils/custom-toast-handlers";
import { useOptimisticUserMessage } from "#/hooks/use-optimistic-user-message";
import { useWSErrorMessage } from "#/hooks/use-ws-error-message";
import { ErrorMessageBanner } from "./error-message-banner";
import { shouldRenderEvent } from "./event-content-helpers/should-render-event";
import {
hasUserEvent,
shouldRenderEvent,
} from "./event-content-helpers/should-render-event";
import { useUploadFiles } from "#/hooks/mutation/use-upload-files";
import { useConfig } from "#/hooks/query/use-config";
import { validateFiles } from "#/utils/file-validation";
@ -168,14 +171,14 @@ export function ChatInterface() {
onChatBodyScroll,
};
const userEventsExist = hasUserEvent(events);
return (
<ScrollProvider value={scrollProviderValue}>
<div className="h-full flex flex-col justify-between pr-0 md:pr-4 relative">
{!hasSubstantiveAgentActions &&
!optimisticUserMessage &&
!events.some(
(event) => isOpenHandsAction(event) && event.source === "user",
) && (
!userEventsExist && (
<ChatSuggestions
onSuggestionsClick={(message) =>
dispatch(setMessageToSend(message))
@ -195,7 +198,7 @@ export function ChatInterface() {
</div>
)}
{!isLoadingMessages && (
{!isLoadingMessages && userEventsExist && (
<Messages
messages={events}
isAwaitingUserConfirmation={

View File

@ -45,3 +45,8 @@ export const shouldRenderEvent = (
return true;
};
export const hasUserEvent = (
events: (OpenHandsAction | OpenHandsObservation)[],
) =>
events.some((event) => isOpenHandsAction(event) && event.source === "user");