Skip to content
Merged
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
17 changes: 11 additions & 6 deletions app/actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ 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 } from '@/lib/agents'
import { mapControlOrchestrator } from '@/lib/agents/map-control-orchestrator'
import { inquire, researcher, taskManager, querySuggestor, resolutionSearch, runMapGraph } from '@/lib/agents'
import { initializeComposioMapbox } from '@/mapbox_mcp/composio-mapbox'
import { Composio } from '@composio/core'
import { writer } from '@/lib/agents/writer'
import { saveChat, getSystemPrompt } from '@/lib/actions/chat'
import { Chat, AIMessage } from '@/lib/types'
import { MapStatus } from '@/components/map/map-status'
import { UserMessage } from '@/components/user-message'
import { BotMessage } from '@/components/message'
import { SearchSection } from '@/components/search-section'
Expand Down Expand Up @@ -426,13 +426,18 @@ async function submit(formData?: FormData, skip?: boolean) {

try {
// Use the Orchestrator with fallback to basic enricher handled internally if needed
console.log('🚀 Starting Map Control Orchestrator...');
locationResponse = await mapControlOrchestrator(answer, {
console.log("🚀 Starting LangGraph Map Orchestrator...");
const statusStream = createStreamableUI(<MapStatus status="Initializing..." />);
uiStream.append(statusStream.value);

locationResponse = await runMapGraph(answer, {
mcpClient,
connectionId,
enableFeedbackLoop: false // Disable for now to reduce latency
onStatusUpdate: (status) => {
statusStream.update(<MapStatus status={status} />);
}
});
console.log('✨ Orchestrator finished:', locationResponse);
statusStream.done();
} catch (e) {
Comment on lines +429 to 441
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

statusStream.done() is only called on the success path. If runMapGraph(...) throws, the UI stream created by createStreamableUI(<MapStatus ... />) may never be finalized, which can leave the client in a perpetual “loading”/spinner state and potentially leak resources.

This is particularly likely given MCP/network calls in the graph. Finalizing the stream in a finally block (or calling .error(...)/.done() in the catch) will make the UI deterministic.

Suggestion

Move statusStream.done() into a finally to guarantee termination, and optionally update status on failure.

const statusStream = createStreamableUI(<MapStatus status="Initializing..." />)
uiStream.append(statusStream.value)

try {
  locationResponse = await runMapGraph(answer, {
    mcpClient,
    connectionId,
    onStatusUpdate: (status) => statusStream.update(<MapStatus status={status} />),
  })
} catch (e) {
  statusStream.update(<MapStatus status="Map orchestration failed; falling back..." />)
  throw e
} finally {
  statusStream.done()
}

Reply with "@CharlieHelps yes please" if you'd like me to add a commit with this change.

console.error("Error during map orchestration:", e);
// Fallback to basic enricher
Expand Down
Loading