From fbb542a3c7149662ac290f991820b3a5a802f985 Mon Sep 17 00:00:00 2001 From: mawkone Date: Mon, 1 Jun 2026 13:51:46 -0700 Subject: [PATCH] debug(gemini): add /api/chat/debug endpoint to capture raw response --- vibn-frontend/app/api/chat/debug/route.ts | 14 ++++++++++++++ vibn-frontend/lib/ai/gemini-chat.ts | 8 ++++++++ 2 files changed, 22 insertions(+) create mode 100644 vibn-frontend/app/api/chat/debug/route.ts diff --git a/vibn-frontend/app/api/chat/debug/route.ts b/vibn-frontend/app/api/chat/debug/route.ts new file mode 100644 index 00000000..580bad08 --- /dev/null +++ b/vibn-frontend/app/api/chat/debug/route.ts @@ -0,0 +1,14 @@ +import { NextResponse } from 'next/server'; + +// Global variable to store the last raw Gemini response for easy debugging +let lastGeminiResponse: any = null; + +export function setLastGeminiResponse(resp: any) { + lastGeminiResponse = resp; +} + +export async function GET() { + return NextResponse.json({ + lastResponse: lastGeminiResponse || "No requests captured yet since last deploy. Send a message from the desktop first." + }); +} diff --git a/vibn-frontend/lib/ai/gemini-chat.ts b/vibn-frontend/lib/ai/gemini-chat.ts index 9f0740af..71b578b6 100644 --- a/vibn-frontend/lib/ai/gemini-chat.ts +++ b/vibn-frontend/lib/ai/gemini-chat.ts @@ -138,6 +138,14 @@ export async function callGeminiChat(opts: { JSON.stringify(response, null, 2), ); + try { + const { setLastGeminiResponse } = + await import("../../app/api/chat/debug/route"); + setLastGeminiResponse(response); + } catch (e) { + console.warn("Failed to set debug response:", e); + } + let text = ""; let thoughts = ""; const toolCalls: ToolCall[] = [];