From 7cca4ecfaa1fee1fcf773aeb6cb05a2b3b18721c Mon Sep 17 00:00:00 2001 From: "coderabbitai[bot]" <136622811+coderabbitai[bot]@users.noreply.github.com> Date: Fri, 26 Jun 2026 17:31:08 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20CodeRabbit=20Chat:=20Fix=20token?= =?UTF-8?q?=20inference=20and=20merge=20conflicts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/actions.tsx | 8 ++-- app/actions.tsx.patch | 27 ----------- app/actions.tsx.tmp | 100 ---------------------------------------- lib/actions/calendar.ts | 17 ------- 4 files changed, 5 insertions(+), 147 deletions(-) delete mode 100644 app/actions.tsx.patch delete mode 100644 app/actions.tsx.tmp diff --git a/app/actions.tsx b/app/actions.tsx index 2bfb6a18..ad2ea73a 100644 --- a/app/actions.tsx +++ b/app/actions.tsx @@ -6,13 +6,13 @@ import { getAIState, getMutableAIState } from 'ai/rsc' -import { CoreMessage, ToolResultPart, TextPart, ImagePart } from 'ai' +import { CoreMessage, ToolResultPart } from 'ai' import { nanoid } from '@/lib/utils' import type { FeatureCollection } from 'geojson' import { Spinner } from '@/components/ui/spinner' import { Section } from '@/components/section' import { FollowupPanel } from '@/components/followup-panel' -import { inquire, researcher, taskManager, querySuggestor, resolutionSearch, type DrawnFeature } from '@/lib/agents' +import { inquire, researcher, querySuggestor, resolutionSearch, type DrawnFeature } from '@/lib/agents' import { writer } from '@/lib/agents/writer' import { saveChat, getSystemPrompt, generateReportContext, getDrawingContext } from '@/lib/actions/chat' import { Chat, AIMessage } from '@/lib/types' @@ -203,7 +203,9 @@ async function submit(formData?: FormData, skip?: boolean) { const userInput = skip ? `What's next?` - : (formData?.get('input') as string) || ''; + : (formData?.get('related_query') as string) || + (formData?.get('input') as string) || + ''; const content: CoreMessage['content'] = [{ type: 'text', text: userInput }]; const messages: CoreMessage[] = [...(aiState.get().messages as any[])].filter( diff --git a/app/actions.tsx.patch b/app/actions.tsx.patch deleted file mode 100644 index 2572f2ff..00000000 --- a/app/actions.tsx.patch +++ /dev/null @@ -1,27 +0,0 @@ -<<<<<<< SEARCH - const action = formData?.get('action') as string; - const drawnFeaturesString = formData?.get('drawnFeatures') as string; - let drawnFeatures: DrawnFeature[] = []; - try { - drawnFeatures = drawnFeaturesString ? JSON.parse(drawnFeaturesString) : []; - } catch (e) { - console.error('Failed to parse drawnFeatures:', e); - } -======= - const action = formData?.get('action') as string; - const drawnFeaturesString = formData?.get('drawnFeatures') as string; - let drawnFeatures: DrawnFeature[] = []; - try { - drawnFeatures = drawnFeaturesString ? JSON.parse(drawnFeaturesString) : []; - } catch (e) { - console.error('Failed to parse drawnFeatures:', e); - } - - const chatId = aiState.get().chatId; - if (chatId && drawnFeatures.length === 0) { - const drawingContext = await getDrawingContext(chatId); - if (drawingContext) { - drawnFeatures = (drawingContext as any).drawnFeatures || []; - } - } ->>>>>>> REPLACE diff --git a/app/actions.tsx.tmp b/app/actions.tsx.tmp deleted file mode 100644 index 5c1e9f02..00000000 --- a/app/actions.tsx.tmp +++ /dev/null @@ -1,100 +0,0 @@ -const action = formData?.get("action") as string; const drawnFeaturesString = formData?.get("drawnFeatures") as string; let drawnFeatures: DrawnFeature[] = []; try { drawnFeatures = drawnFeaturesString ? JSON.parse(drawnFeaturesString) : []; } catch (e) { console.error("Failed to parse drawnFeatures:", e); } const chatId = aiState.get().chatId; if (chatId && drawnFeatures.length === 0) { const drawingContext = await getDrawingContext(chatId); if (drawingContext) { drawnFeatures = (drawingContext as any).drawnFeatures || []; } } - console.error('Failed to parse drawnFeatures:', e); - } - - if (action === 'generate_report_context') { - const messagesString = formData?.get('messages'); - if (typeof messagesString !== 'string') { - return { title: 'QCX Intelligence Analysis', summary: 'Automated executive summary is currently unavailable.' }; - } - try { - const messages = JSON.parse(messagesString) as AIMessage[]; - return await generateReportContext(messages); - } catch (e) { - console.error('Failed to parse messages for report context:', e); - return { title: 'QCX Intelligence Analysis', summary: 'Automated executive summary is currently unavailable.' }; - } - } - - if (action === 'resolution_search') { - const file_mapbox = formData?.get('file_mapbox') as File; - const file_google = formData?.get('file_google') as File; - const file = (formData?.get('file') as File) || file_mapbox || file_google; - const timezone = (formData?.get('timezone') as string) || 'UTC'; - const lat = formData?.get('latitude') ? parseFloat(formData.get('latitude') as string) : undefined; - const lng = formData?.get('longitude') ? parseFloat(formData.get('longitude') as string) : undefined; - const location = (lat !== undefined && lng !== undefined) ? { lat, lng } : undefined; - - if (!file) { - throw new Error('No file provided for resolution search.'); - } - - const mapboxBuffer = file_mapbox ? await file_mapbox.arrayBuffer() : null; - const mapboxDataUrl = mapboxBuffer ? `data:${file_mapbox.type};base64,${Buffer.from(mapboxBuffer).toString('base64')}` : null; - - const googleBuffer = file_google ? await file_google.arrayBuffer() : null; - const googleDataUrl = googleBuffer ? `data:${file_google.type};base64,${Buffer.from(googleBuffer).toString('base64')}` : null; - - const buffer = await file.arrayBuffer(); - const dataUrl = `data:${file.type};base64,${Buffer.from(buffer).toString('base64')}`; - - const messages: CoreMessage[] = [...(aiState.get().messages as any[])].filter( - (message: any) => - message.role !== 'tool' && - message.type !== 'followup' && - message.type !== 'related' && - message.type !== 'end' && - message.type !== 'resolution_search_result' - ); - - const userInput = 'Analyze this map view.'; - const content: CoreMessage['content'] = [ - { type: 'text', text: userInput }, - { type: 'image', image: dataUrl, mimeType: file.type } - ]; - - aiState.update({ - ...aiState.get(), - messages: [ - ...aiState.get().messages, - { id: nanoid(), role: 'user', content, type: 'input' } - ] - }); - messages.push({ role: 'user', content }); - - const summaryStream = createStreamableValue('Analyzing map view...'); - const groupeId = nanoid(); - - async function processResolutionSearch() { - try { - const streamResult = await resolutionSearch(messages, timezone, drawnFeatures, location); - - let fullSummary = ''; - for await (const partialObject of streamResult.partialObjectStream) { - if (partialObject.summary) { - fullSummary = partialObject.summary; - summaryStream.update(fullSummary); - } - } - - const analysisResult = await streamResult.object; - summaryStream.done(analysisResult.summary || 'Analysis complete.'); - - // Reconstruct standard GeoJSON from flattened schema if present - let geoJson: FeatureCollection | null = null; - if (analysisResult.geoJson && analysisResult.geoJson.features) { - geoJson = { - type: 'FeatureCollection', - features: analysisResult.geoJson.features.map(f => ({ - type: 'Feature', - geometry: { - type: f.geometryType as any, - coordinates: f.coordinates as any - }, - properties: { - name: f.name, - description: f.description - } - })) - }; - } diff --git a/lib/actions/calendar.ts b/lib/actions/calendar.ts index d8fa7d15..8df79a4e 100644 --- a/lib/actions/calendar.ts +++ b/lib/actions/calendar.ts @@ -137,23 +137,6 @@ export async function saveNote(noteData: NewCalendarNote | CalendarNote): Promis return savedNote; }); - if (result && result.chatId) { - const { createMessage } = await import('./chat-db'); - await createMessage({ - chatId: result.chatId, - userId: userId, - role: 'data', - content: JSON.stringify({ - type: 'calendar_note', - note: { - ...result, - locationTags, - userTags - }, - }), - }); - } - return result; } catch (error) { console.error('Error saving note:', error);