mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-03-21 18:58:04 +00:00
feat(ui): send finding context to Lighthouse chat
This commit is contained in:
@@ -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<Record<string, string | string[] | undefined>>;
|
||||
}) {
|
||||
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}
|
||||
/>
|
||||
</div>
|
||||
</ContentLayout>
|
||||
|
||||
@@ -608,7 +608,7 @@ export function ResourceDetailDrawerContent({
|
||||
|
||||
{/* Lighthouse AI button */}
|
||||
<a
|
||||
href="/lighthouse"
|
||||
href={`/lighthouse?${new URLSearchParams({ prompt: `Analyze this security finding and provide remediation guidance:\n\n- **Finding**: ${checkMeta.checkTitle}\n- **Check ID**: ${checkMeta.checkId}\n- **Severity**: ${f?.severity ?? "unknown"}\n- **Status**: ${f?.status ?? "unknown"}${f?.statusExtended ? `\n- **Detail**: ${f.statusExtended}` : ""}${checkMeta.risk ? `\n- **Risk**: ${checkMeta.risk}` : ""}` }).toString()}`}
|
||||
className="flex items-center gap-1.5 rounded-lg px-4 py-3 text-sm font-bold text-slate-950 transition-opacity hover:opacity-90"
|
||||
style={{
|
||||
background: "linear-gradient(96deg, #2EE59B 3.55%, #62DFF0 98.85%)",
|
||||
|
||||
@@ -61,6 +61,7 @@ interface ChatProps {
|
||||
providers: Provider[];
|
||||
defaultProviderId?: LighthouseProvider;
|
||||
defaultModelId?: string;
|
||||
initialPrompt?: string;
|
||||
}
|
||||
|
||||
interface SelectedModel {
|
||||
@@ -102,6 +103,7 @@ export const Chat = ({
|
||||
providers: initialProviders,
|
||||
defaultProviderId,
|
||||
defaultModelId,
|
||||
initialPrompt,
|
||||
}: ChatProps) => {
|
||||
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([]);
|
||||
|
||||
Reference in New Issue
Block a user