mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-25 21:36:52 +08:00
fix(frontend): observation events and action events (v1 conversations) (#12066)
Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
parent
0607614372
commit
f98e7fbc49
@ -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):
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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} />
|
||||
|
||||
@ -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" &&
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user