Fix think observation redundant rendering in frontend (#10409)

Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
Xingyao Wang 2025-08-16 22:55:03 -04:00 committed by GitHub
parent 315d391414
commit ef3e0c8dfe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 5 deletions

View File

@ -16,6 +16,8 @@ const COMMON_NO_RENDER_LIST: OpenHandsEventType[] = [
const ACTION_NO_RENDER_LIST: OpenHandsEventType[] = ["recall"];
const OBSERVATION_NO_RENDER_LIST: OpenHandsEventType[] = ["think"];
export const shouldRenderEvent = (
event: OpenHandsAction | OpenHandsObservation,
) => {
@ -35,7 +37,10 @@ export const shouldRenderEvent = (
return false;
}
return !COMMON_NO_RENDER_LIST.includes(event.observation);
const noRenderList = COMMON_NO_RENDER_LIST.concat(
OBSERVATION_NO_RENDER_LIST,
);
return !noRenderList.includes(event.observation);
}
return true;

View File

@ -117,7 +117,7 @@ export function EventMessage({
}
if (hasObservationPair && isOpenHandsAction(event)) {
if (hasThoughtProperty(event.args)) {
if (hasThoughtProperty(event.args) && event.action !== "think") {
return (
<div>
<ChatMessage
@ -243,9 +243,11 @@ export function EventMessage({
return (
<div>
{isOpenHandsAction(event) && hasThoughtProperty(event.args) && (
<ChatMessage type="agent" message={event.args.thought} />
)}
{isOpenHandsAction(event) &&
hasThoughtProperty(event.args) &&
event.action !== "think" && (
<ChatMessage type="agent" message={event.args.thought} />
)}
<GenericEventMessage
title={getEventContent(event).title}