diff --git a/frontend/src/state/chat-slice.ts b/frontend/src/state/chat-slice.ts index fc3da4e77099..9c250aad0ce9 100644 --- a/frontend/src/state/chat-slice.ts +++ b/frontend/src/state/chat-slice.ts @@ -5,6 +5,8 @@ import { OpenHandsObservation, CommandObservation, IPythonObservation, + WriteObservation, + ReadObservation, } from "#/types/core/observations"; import { OpenHandsAction } from "#/types/core/actions"; import { OpenHandsEventType } from "#/types/core/base"; @@ -142,9 +144,14 @@ export const chatSlice = createSlice({ // For IPython, we consider it successful if there's no error message const ipythonObs = observation.payload as IPythonObservation; causeMessage.success = !ipythonObs.message.toLowerCase().includes("error"); - } else if (observationID === "write" || observationID === "read") { - // For file operations, we consider them successful if there's no error message - causeMessage.success = !observation.payload.message.toLowerCase().includes("error"); + } else if (observationID === "write") { + // For write operations, we consider them successful if there's no error message + const writeObs = observation.payload as WriteObservation; + causeMessage.success = !writeObs.message.toLowerCase().includes("error"); + } else if (observationID === "read") { + // For read operations, we consider them successful if there's no error message + const readObs = observation.payload as ReadObservation; + causeMessage.success = !readObs.message.toLowerCase().includes("error"); } if (observationID === "run" || observationID === "run_ipython") { diff --git a/frontend/src/types/core/observations.ts b/frontend/src/types/core/observations.ts index 0b95099a8384..7ddc3f05dd94 100644 --- a/frontend/src/types/core/observations.ts +++ b/frontend/src/types/core/observations.ts @@ -52,6 +52,21 @@ export interface BrowseObservation extends OpenHandsObservationEvent<"browse"> { }; } +export interface WriteObservation extends OpenHandsObservationEvent<"write"> { + source: "agent"; + extras: { + path: string; + content: string; + }; +} + +export interface ReadObservation extends OpenHandsObservationEvent<"read"> { + source: "agent"; + extras: { + path: string; + }; +} + export interface ErrorObservation extends OpenHandsObservationEvent<"error"> { source: "user"; extras: { @@ -65,4 +80,6 @@ export type OpenHandsObservation = | IPythonObservation | DelegateObservation | BrowseObservation + | WriteObservation + | ReadObservation | ErrorObservation;