diff --git a/ui/app/(prowler)/lighthouse/_actions/lighthouse-v2.adapter.ts b/ui/app/(prowler)/lighthouse/_actions/lighthouse-v2.adapter.ts index 448057e83e..7ed1089370 100644 --- a/ui/app/(prowler)/lighthouse/_actions/lighthouse-v2.adapter.ts +++ b/ui/app/(prowler)/lighthouse/_actions/lighthouse-v2.adapter.ts @@ -271,15 +271,6 @@ export function buildLighthouseV2MessagePayload(input: { }; } -export function buildLighthouseV2CancelRunPayload(taskId: string) { - return { - data: { - type: "lighthouse-run-cancellations", - attributes: { task_id: taskId }, - }, - }; -} - export function validateLighthouseV2ConfigurationInput(input: { providerType: LighthouseV2ProviderType; credentials?: LighthouseV2Credentials; diff --git a/ui/app/(prowler)/lighthouse/_actions/lighthouse-v2.ts b/ui/app/(prowler)/lighthouse/_actions/lighthouse-v2.ts index 2cf3c98a7b..51e583a6b8 100644 --- a/ui/app/(prowler)/lighthouse/_actions/lighthouse-v2.ts +++ b/ui/app/(prowler)/lighthouse/_actions/lighthouse-v2.ts @@ -12,13 +12,11 @@ import type { LighthouseV2Session, LighthouseV2SupportedModel, LighthouseV2SupportedProvider, - LighthouseV2Task, } from "@/app/(prowler)/lighthouse/_types"; import { apiBaseUrl, getAuthHeaders } from "@/lib/helper"; import { handleApiError, handleApiResponse } from "@/lib/server-actions-helper"; import { - buildLighthouseV2CancelRunPayload, buildLighthouseV2ConfigurationPayload, buildLighthouseV2ConfigurationUpdatePayload, buildLighthouseV2MessagePayload, @@ -265,21 +263,6 @@ export async function sendLighthouseV2Message( } } -export async function cancelLighthouseV2Run( - sessionId: string, - taskId: string, -): Promise> { - return mutateSingle( - `/lighthouse/sessions/${encodeURIComponent(sessionId)}/cancel-run`, - { - method: "POST", - body: JSON.stringify(buildLighthouseV2CancelRunPayload(taskId)), - }, - mapLighthouseV2Task, - "/lighthouse", - ); -} - async function getCollection( path: string, mapper: (resource: TResource) => TOutput, diff --git a/ui/app/(prowler)/lighthouse/_components/chat/composer.tsx b/ui/app/(prowler)/lighthouse/_components/chat/composer.tsx index 30d929cd2e..1551c9ed2d 100644 --- a/ui/app/(prowler)/lighthouse/_components/chat/composer.tsx +++ b/ui/app/(prowler)/lighthouse/_components/chat/composer.tsx @@ -25,7 +25,6 @@ interface ChatComposerPanelProps { modelSelector: ReactNode; selectedConfigurationConnected: boolean; onInputChange: (value: string) => void; - onStop: () => void; onSubmit: (event: SubmitEvent) => void; onSubmitText: (text: string) => Promise; } @@ -87,9 +86,6 @@ interface ChatComposerProps { modelSelector: ReactNode; selectedConfigurationConnected: boolean; onInputChange: (value: string) => void; - // Kept on the contract but unused for now: the backend can't cancel a run yet, - // so the stop control is replaced by a non-interactive spinner. - onStop: () => void; onSubmit: (event: SubmitEvent) => void; onSubmitText: (text: string) => Promise; } diff --git a/ui/app/(prowler)/lighthouse/_components/chat/empty-state.tsx b/ui/app/(prowler)/lighthouse/_components/chat/empty-state.tsx index 2e7d62929c..6c2c2eb128 100644 --- a/ui/app/(prowler)/lighthouse/_components/chat/empty-state.tsx +++ b/ui/app/(prowler)/lighthouse/_components/chat/empty-state.tsx @@ -43,7 +43,6 @@ interface ChatEmptyStateProps { modelSelector: ReactNode; selectedConfigurationConnected: boolean; onInputChange: (value: string) => void; - onStop: () => void; onSubmit: (event: SubmitEvent) => void; onSubmitText: (text: string) => Promise; } diff --git a/ui/app/(prowler)/lighthouse/_components/chat/lighthouse-v2-chat-page.test.tsx b/ui/app/(prowler)/lighthouse/_components/chat/lighthouse-v2-chat-page.test.tsx index aa376c97e2..8d3fc1ab9b 100644 --- a/ui/app/(prowler)/lighthouse/_components/chat/lighthouse-v2-chat-page.test.tsx +++ b/ui/app/(prowler)/lighthouse/_components/chat/lighthouse-v2-chat-page.test.tsx @@ -59,13 +59,11 @@ function stubEventSource() { } const { - cancelRunMock, createSessionMock, getMessagesMock, sendMessageMock, updateConfigurationMock, } = vi.hoisted(() => ({ - cancelRunMock: vi.fn(), createSessionMock: vi.fn(), getMessagesMock: vi.fn(), sendMessageMock: vi.fn(), @@ -73,7 +71,6 @@ const { })); vi.mock("@/app/(prowler)/lighthouse/_actions", () => ({ - cancelLighthouseV2Run: cancelRunMock, createLighthouseV2Session: createSessionMock, getLighthouseV2Messages: getMessagesMock, sendLighthouseV2Message: sendMessageMock, @@ -138,7 +135,6 @@ describe("LighthouseV2ChatPage", () => { configurable: true, value: vi.fn(), }); - cancelRunMock.mockReset(); createSessionMock.mockReset(); getMessagesMock.mockReset(); sendMessageMock.mockReset(); diff --git a/ui/app/(prowler)/lighthouse/_components/chat/lighthouse-v2-chat-page.tsx b/ui/app/(prowler)/lighthouse/_components/chat/lighthouse-v2-chat-page.tsx index 4f59c963d9..e1c875885b 100644 --- a/ui/app/(prowler)/lighthouse/_components/chat/lighthouse-v2-chat-page.tsx +++ b/ui/app/(prowler)/lighthouse/_components/chat/lighthouse-v2-chat-page.tsx @@ -3,7 +3,6 @@ import { type SubmitEvent, useRef, useState } from "react"; import { - cancelLighthouseV2Run, createLighthouseV2Session, getLighthouseV2Messages, sendLighthouseV2Message, @@ -151,7 +150,6 @@ export function LighthouseV2ChatPage({ ) => { if ( event.type === LIGHTHOUSE_V2_SSE_EVENT.MESSAGE_END || - event.type === LIGHTHOUSE_V2_SSE_EVENT.RUN_CANCELLED || event.type === LIGHTHOUSE_V2_SSE_EVENT.ERROR ) { closeStream(); @@ -195,11 +193,6 @@ export function LighthouseV2ChatPage({ source.addEventListener("message.end", (event) => applyEvent(parseStreamEvent(event, LIGHTHOUSE_V2_SSE_EVENT.MESSAGE_END)), ); - source.addEventListener("run.cancelled", (event) => - applyEvent( - parseStreamEvent(event, LIGHTHOUSE_V2_SSE_EVENT.RUN_CANCELLED), - ), - ); source.addEventListener("error", (event) => { if (event instanceof MessageEvent) { applyEvent(parseStreamEvent(event, LIGHTHOUSE_V2_SSE_EVENT.ERROR)); @@ -339,25 +332,6 @@ export function LighthouseV2ChatPage({ void submitMessage(input); }; - const handleStop = async () => { - if (!activeSessionId || !streamState.activeTaskId) return; - const taskId = streamState.activeTaskId; - const result = await cancelLighthouseV2Run(activeSessionId, taskId); - closeStream(); - setStreamState((current) => - reduceLighthouseV2Event(current, { - type: "run.cancelled", - taskId, - }), - ); - setBlockedByConflict(false); - await refreshMessages(activeSessionId); - notifyLighthouseV2SessionsChanged(); - if ("error" in result) { - setFeedback(result.error); - } - }; - useMountEffect(() => { if (initialSessionId && initialActiveTaskId && initialStreamUrl) { startStream(initialStreamUrl, initialSessionId); @@ -427,7 +401,6 @@ export function LighthouseV2ChatPage({ ), selectedConfigurationConnected: selectedConfiguration?.connected === true, onInputChange: setInput, - onStop: handleStop, onSubmit: handleSubmit, onSubmitText: submitMessage, }; diff --git a/ui/app/(prowler)/lighthouse/_lib/event-reducer.test.ts b/ui/app/(prowler)/lighthouse/_lib/event-reducer.test.ts index 37000bf035..6d40f09bc0 100644 --- a/ui/app/(prowler)/lighthouse/_lib/event-reducer.test.ts +++ b/ui/app/(prowler)/lighthouse/_lib/event-reducer.test.ts @@ -112,22 +112,6 @@ describe("event-reducer", () => { expect(next.activeTaskId).toBeNull(); }); - it("should mark run cancellation as terminal without error", () => { - // Given - const state = createInitialLighthouseV2StreamState("task-1"); - - // When - const next = reduceLighthouseV2Event(state, { - type: "run.cancelled", - taskId: "task-1", - }); - - // Then - expect(next.status).toBe("cancelled"); - expect(next.error).toBeUndefined(); - expect(next.activeTaskId).toBeNull(); - }); - it("should store terminal errors", () => { // Given const state = createInitialLighthouseV2StreamState("task-1"); diff --git a/ui/app/(prowler)/lighthouse/_lib/event-reducer.ts b/ui/app/(prowler)/lighthouse/_lib/event-reducer.ts index f311d86198..02da6b151a 100644 --- a/ui/app/(prowler)/lighthouse/_lib/event-reducer.ts +++ b/ui/app/(prowler)/lighthouse/_lib/event-reducer.ts @@ -7,7 +7,6 @@ export const LIGHTHOUSE_V2_STREAM_STATUS = { IDLE: "idle", STREAMING: "streaming", COMPLETED: "completed", - CANCELLED: "cancelled", ERROR: "error", DISCONNECTED: "disconnected", } as const; @@ -141,12 +140,6 @@ export function reduceLighthouseV2Event( activeTaskId: null, messageId: event.messageId, }; - case LIGHTHOUSE_V2_SSE_EVENT.RUN_CANCELLED: - return { - ...state, - status: LIGHTHOUSE_V2_STREAM_STATUS.CANCELLED, - activeTaskId: null, - }; case LIGHTHOUSE_V2_SSE_EVENT.ERROR: return { ...state, diff --git a/ui/app/(prowler)/lighthouse/_lib/stream-event-parser.ts b/ui/app/(prowler)/lighthouse/_lib/stream-event-parser.ts index 113985fa27..617b82c23f 100644 --- a/ui/app/(prowler)/lighthouse/_lib/stream-event-parser.ts +++ b/ui/app/(prowler)/lighthouse/_lib/stream-event-parser.ts @@ -37,12 +37,6 @@ export function parseStreamEvent( messageId: readString(data, "message_id"), }; } - if (type === LIGHTHOUSE_V2_SSE_EVENT.RUN_CANCELLED) { - return { - type, - taskId: readString(data, "task_id"), - }; - } return { type: LIGHTHOUSE_V2_SSE_EVENT.ERROR, code: readString(data, "code"), diff --git a/ui/app/(prowler)/lighthouse/_types/events.ts b/ui/app/(prowler)/lighthouse/_types/events.ts index 54c4ab3aaa..cccff312e9 100644 --- a/ui/app/(prowler)/lighthouse/_types/events.ts +++ b/ui/app/(prowler)/lighthouse/_types/events.ts @@ -3,7 +3,6 @@ export const LIGHTHOUSE_V2_SSE_EVENT = { TOOL_CALL_START: "tool_call.start", TOOL_CALL_END: "tool_call.end", MESSAGE_END: "message.end", - RUN_CANCELLED: "run.cancelled", ERROR: "error", DISCONNECT: "disconnect", } as const; @@ -33,11 +32,6 @@ export interface LighthouseV2MessageEndEvent { messageId: string; } -export interface LighthouseV2RunCancelledEvent { - type: typeof LIGHTHOUSE_V2_SSE_EVENT.RUN_CANCELLED; - taskId: string; -} - export interface LighthouseV2ErrorEvent { type: typeof LIGHTHOUSE_V2_SSE_EVENT.ERROR; code: string; @@ -53,6 +47,5 @@ export type LighthouseV2SSEEvent = | LighthouseV2ToolCallStartEvent | LighthouseV2ToolCallEndEvent | LighthouseV2MessageEndEvent - | LighthouseV2RunCancelledEvent | LighthouseV2ErrorEvent | LighthouseV2DisconnectEvent;