Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions app/actions.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,6 +8,7 @@ import {
} from 'ai/rsc'
import { CoreMessage, ToolResultPart } from 'ai'
import { nanoid } from '@/lib/utils'

Comment thread
coderabbitai[bot] marked this conversation as resolved.
import type { FeatureCollection } from 'geojson'
import { Spinner } from '@/components/ui/spinner'
import { Section } from '@/components/section'
Expand DownExpand Up@@ -91,13 +92,13 @@ async function submit(formData?: FormData, skip?: boolean) {
...aiState.get(),
messages: [
...aiState.get().messages,
{ id: nanoid(), role: 'user', content, type: 'input' }
{ id: (formData?.get('id') as string) || nanoid(), role: 'user', content, type: 'input' }
]
});
messages.push({ role: 'user', content });

const summaryStream = createStreamableValue<string>('Analyzing map view...');
const groupeId = nanoid();
const groupeId = (formData?.get('id') as string) || nanoid();

async function processResolutionSearch() {
try {
Expand DownExpand Up@@ -214,7 +215,7 @@ async function submit(formData?: FormData, skip?: boolean) {
);

return {
id: nanoid(),
id: (formData?.get('id') as string) || nanoid(),
isGenerating: isGenerating.value,
component: uiStream.value,
isCollapsed: isCollapsed.value
Expand All@@ -234,14 +235,14 @@ async function submit(formData?: FormData, skip?: boolean) {

const content = JSON.stringify(Object.fromEntries(formData!));
const type = 'input';
const groupeId = nanoid();
const groupeId = (formData?.get('id') as string) || nanoid();

aiState.update({
...aiState.get(),
messages: [
...aiState.get().messages,
{
id: nanoid(),
id: (formData?.get('id') as string) || nanoid(),
role: 'user',
content,
type,
Expand DownExpand Up@@ -291,7 +292,7 @@ async function submit(formData?: FormData, skip?: boolean) {
uiStream.done();

return {
id: nanoid(),
id: (formData?.get('id') as string) || nanoid(),
isGenerating: isGenerating.value,
component: uiStream.value,
isCollapsed: isCollapsed.value
Expand All@@ -301,7 +302,7 @@ async function submit(formData?: FormData, skip?: boolean) {
if (!userInput && !file) {
isGenerating.done(false)
return {
id: nanoid(),
id: (formData?.get('id') as string) || nanoid(),
isGenerating: isGenerating.value,
component: null,
isCollapsed: isCollapsed.value
Expand DownExpand Up@@ -384,7 +385,7 @@ async function submit(formData?: FormData, skip?: boolean) {
messages: [
...aiState.get().messages,
{
id: nanoid(),
id: (formData?.get('id') as string) || nanoid(),
role: 'user',
content,
type
Expand DownExpand Up@@ -420,7 +421,7 @@ async function submit(formData?: FormData, skip?: boolean) {
messages: [
...aiState.get().messages,
{
id: nanoid(),
id: (formData?.get('id') as string) || nanoid(),
role: 'assistant',
content: `inquiry: ${inquiry?.question}`
}
Expand DownExpand Up@@ -540,7 +541,7 @@ async function submit(formData?: FormData, skip?: boolean) {
processEvents()

return {
id: nanoid(),
id: (formData?.get('id') as string) || nanoid(),
isGenerating: isGenerating.value,
component: uiStream.value,
isCollapsed: isCollapsed.value
Expand DownExpand Up@@ -630,7 +631,7 @@ export const AI = createAI<AIState, UIState>({
const updatedMessages: AIMessage[] = [
...messages,
{
id: nanoid(),
id: (formData?.get('id') as string) || nanoid(),
role: 'assistant',
content: `end`,
type: 'end'
Expand Down
3 changes: 2 additions & 1 deletion components/followup-panel.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,7 +20,8 @@ export function FollowupPanel() {
event.preventDefault()
const formData = new FormData()
formData.append("input", input)
formData.append("action", "resolution_search")

formData.append("id", nanoid())

const userMessage = {
id: nanoid(),
Expand Down
1 change: 1 addition & 0 deletions components/header-search-button.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -128,6 +128,7 @@ export function HeaderSearchButton() {
formData.append('file', (mapboxBlob || googleBlob)!, 'map_capture.png')

formData.append('action', 'resolution_search')
formData.append('id', nanoid())
formData.append('timezone', mapData.currentTimezone || 'UTC')
formData.append('drawnFeatures', JSON.stringify(mapData.drawnFeatures || []))

Expand Down
1 change: 1 addition & 0 deletions components/resolution-carousel.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,6 +52,7 @@ export function ResolutionCarousel({ mapboxImage, googleImage, initialImage }: R
const formData = new FormData()
formData.append('file', blob, 'google_analysis.png')
formData.append('action', 'resolution_search')
formData.append('id', nanoid())

const responseMessage = await actions.submit(formData)
setMessages((currentMessages: any[]) => [...currentMessages, responseMessage as any])
Expand Down