From 895fb80ea5c82fd9195e0fb7c4f41e02bd569198 Mon Sep 17 00:00:00 2001 From: alejandrobailo Date: Fri, 20 Mar 2026 14:37:50 +0100 Subject: [PATCH] feat(ui): send finding context to Lighthouse chat --- ui/app/(prowler)/lighthouse/page.tsx | 11 ++++++++++- .../resource-detail-drawer-content.tsx | 2 +- ui/components/lighthouse/chat.tsx | 11 +++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/ui/app/(prowler)/lighthouse/page.tsx b/ui/app/(prowler)/lighthouse/page.tsx index 5a9cea2454..eefca03e6b 100644 --- a/ui/app/(prowler)/lighthouse/page.tsx +++ b/ui/app/(prowler)/lighthouse/page.tsx @@ -10,7 +10,15 @@ import { ContentLayout } from "@/components/ui"; export const dynamic = "force-dynamic"; -export default async function AIChatbot() { +export default async function AIChatbot({ + searchParams, +}: { + searchParams: Promise>; +}) { + const params = await searchParams; + const initialPrompt = + typeof params.prompt === "string" ? params.prompt : undefined; + const hasConfig = await isLighthouseConfigured(); if (!hasConfig) { @@ -33,6 +41,7 @@ export default async function AIChatbot() { providers={providersConfig.providers} defaultProviderId={providersConfig.defaultProviderId} defaultModelId={providersConfig.defaultModelId} + initialPrompt={initialPrompt} /> diff --git a/ui/components/findings/table/resource-detail-drawer/resource-detail-drawer-content.tsx b/ui/components/findings/table/resource-detail-drawer/resource-detail-drawer-content.tsx index 803678425b..1f8fc245c8 100644 --- a/ui/components/findings/table/resource-detail-drawer/resource-detail-drawer-content.tsx +++ b/ui/components/findings/table/resource-detail-drawer/resource-detail-drawer-content.tsx @@ -608,7 +608,7 @@ export function ResourceDetailDrawerContent({ {/* Lighthouse AI button */} { const { toast } = useToast(); @@ -306,6 +308,15 @@ export const Chat = ({ } }; + // Auto-send initial prompt from URL (e.g., finding context from drawer) + const initialPromptSentRef = useRef(false); + useEffect(() => { + if (initialPrompt && !initialPromptSentRef.current) { + initialPromptSentRef.current = true; + sendMessage({ text: initialPrompt }); + } + }, [initialPrompt, sendMessage]); + // Handlers const handleNewChat = () => { setMessages([]);