Skip to content

πŸ™Œ OpenHands: AI-Driven Development

feat: Use interrupt endpoint for agent pause UI (#14972)

Rohit Malhotra36cf22b7800c
diff --git a/frontend/__tests__/api/v1-conversation-service.test.ts b/frontend/__tests__/api/v1-conversation-service.test.ts
index 09b843244a..64e227bf17 100644
--- a/frontend/__tests__/api/v1-conversation-service.test.ts
+++ b/frontend/__tests__/api/v1-conversation-service.test.ts
@@ -114,4 +114,35 @@ describe("V1ConversationService", () => {
expect(headers).toHaveProperty("Content-Type", "multipart/form-data");
});
});
+
+ describe("interruptConversation", () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ (axios.post as Mock).mockResolvedValue({ data: { success: true } });
+ });
+
+ afterEach(() => {
+ vi.resetAllMocks();
+ });
+
+ it("calls the runtime interrupt endpoint with session headers", async () => {
+ const conversationId = "conv-123";
+ const conversationUrl =
+ "http://localhost:54928/api/conversations/conv-123";
+ const sessionApiKey = "test-api-key";
+
+ const result = await V1ConversationService.interruptConversation(
+ conversationId,
+ conversationUrl,
+ sessionApiKey,
+ );
+
+ expect(result).toEqual({ success: true });
+ expect(axios.post).toHaveBeenCalledWith(
+ "http://localhost:54928/api/conversations/conv-123/interrupt",
+ {},
+ { headers: { "X-Session-API-Key": sessionApiKey } },
+ );
+ });
+ });
});
diff --git a/frontend/src/api/conversation-service/v1-conversation-service.api.ts b/frontend/src/api/conversation-service/v1-conversation-service.api.ts
index 15810d4f8b..41e9ee807d 100644
--- a/frontend/src/api/conversation-service/v1-conversation-service.api.ts
+++ b/frontend/src/api/conversation-service/v1-conversation-service.api.ts
@@ -179,7 +179,7 @@ class V1ConversationService {
}
/**
- * Pause a V1 conversation
+ * Interrupt a V1 conversation
* Uses the custom runtime URL from the conversation
*
* @param conversationId The conversation ID
@@ -187,14 +187,14 @@ class V1ConversationService {
* @param sessionApiKey Session API key for authentication (required for V1)
* @returns Success response
*/
- static async pauseConversation(
+ static async interruptConversation(
conversationId: string,
conversationUrl: string | null | undefined,
sessionApiKey?: string | null,
): Promise<{ success: boolean }> {
const url = this.buildRuntimeUrl(
conversationUrl,
- `/api/conversations/${conversationId}/pause`,
+ `/api/conversations/${conversationId}/interrupt`,
);
const headers = buildSessionHeaders(sessionApiKey);
diff --git a/frontend/src/hooks/mutation/conversation-mutation-utils.ts b/frontend/src/hooks/mutation/conversation-mutation-utils.ts
index 8982f3413e..634d003e33 100644
--- a/frontend/src/hooks/mutation/conversation-mutation-utils.ts
+++ b/frontend/src/hooks/mutation/conversation-mutation-utils.ts
@@ -39,12 +39,12 @@ export const pauseV1ConversationSandbox = async (conversationId: string) => {
};
/**
- * Pause a V1 conversation by fetching the conversation data and pausing it
+ * Interrupt a V1 conversation by fetching the conversation data and interrupting it
*/
-export const pauseV1Conversation = async (conversationId: string) => {
+export const interruptV1Conversation = async (conversationId: string) => {
const { conversationUrl, sessionApiKey } =
await fetchV1ConversationData(conversationId);
- return V1ConversationService.pauseConversation(
+ return V1ConversationService.interruptConversation(
conversationId,
conversationUrl,
sessionApiKey,
diff --git a/frontend/src/hooks/mutation/use-v1-pause-conversation.ts b/frontend/src/hooks/mutation/use-v1-pause-conversation.ts
index 810fdab4d3..2364dc46fc 100644
--- a/frontend/src/hooks/mutation/use-v1-pause-conversation.ts
+++ b/frontend/src/hooks/mutation/use-v1-pause-conversation.ts
@@ -1,12 +1,12 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
-import { pauseV1Conversation } from "./conversation-mutation-utils";
+import { interruptV1Conversation } from "./conversation-mutation-utils";
export const useV1PauseConversation = () => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: (variables: { conversationId: string }) =>
- pauseV1Conversation(variables.conversationId),
+ interruptV1Conversation(variables.conversationId),
onMutate: async () => {
await queryClient.cancelQueries({ queryKey: ["user", "conversations"] });
const previousConversations = queryClient.getQueryData([