fix(frontend): observation events and action events (v1 conversations) (#12066)

Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
Hiep Le 2025-12-17 22:34:28 +07:00 committed by GitHub
parent 0607614372
commit f98e7fbc49
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 20 additions and 2 deletions

View File

@ -94,6 +94,9 @@ class SaasSettingsStore(SettingsStore):
}
self._decrypt_kwargs(kwargs)
settings = Settings(**kwargs)
settings.v1_enabled = True
return settings
async def store(self, item: Settings):

View File

@ -18,6 +18,10 @@ export const shouldRenderEvent = (event: OpenHandsEvent) => {
// For V1, action is an object with kind property
const actionType = event.action.kind;
if (!actionType) {
return false;
}
// Hide user commands from the chat interface
if (actionType === "ExecuteBashAction" && event.source === "user") {
return false;

View File

@ -34,7 +34,12 @@ export function ObservationPairEventMessage({
.map((t) => t.text)
.join("\n");
if (thoughtContent && event.action.kind !== "ThinkAction") {
// Defensive check: ensure action exists and has kind property
if (
thoughtContent &&
event.action?.kind &&
event.action.kind !== "ThinkAction"
) {
return (
<div>
<ChatMessage type="agent" message={thoughtContent} actions={actions} />

View File

@ -54,7 +54,10 @@ export const isObservationEvent = (
): event is ObservationEvent =>
event.source === "environment" &&
"action_id" in event &&
"observation" in event;
"observation" in event &&
event.observation !== null &&
typeof event.observation === "object" &&
"kind" in event.observation;
/**
* Type guard function to check if an event is an agent error event
@ -94,6 +97,9 @@ export const isUserMessageEvent = (
export const isActionEvent = (event: OpenHandsEvent): event is ActionEvent =>
event.source === "agent" &&
"action" in event &&
event.action !== null &&
typeof event.action === "object" &&
"kind" in event.action &&
"tool_name" in event &&
"tool_call_id" in event &&
typeof event.tool_name === "string" &&