Skip to content

πŸ™Œ OpenHands: AI-Driven Development

Fix think observation redundant rendering in frontend (#10409)

Xingyao Wangef3e0c8dfec4
diff --git a/frontend/src/components/features/chat/event-content-helpers/should-render-event.ts b/frontend/src/components/features/chat/event-content-helpers/should-render-event.ts
index e6838a2ab3..0c4a9973a2 100644
--- a/frontend/src/components/features/chat/event-content-helpers/should-render-event.ts
+++ b/frontend/src/components/features/chat/event-content-helpers/should-render-event.ts
@@ -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;
diff --git a/frontend/src/components/features/chat/event-message.tsx b/frontend/src/components/features/chat/event-message.tsx
index fb70982a01..29ad3dc44c 100644
--- a/frontend/src/components/features/chat/event-message.tsx
+++ b/frontend/src/components/features/chat/event-message.tsx
@@ -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}