feat: implement UI fixes and model optimizations#586
Conversation
Co-authored-by: ngoiyaeric <115367894+ngoiyaeric@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
|
|
Warning Rate limit exceeded
To continue reviewing without waiting, purchase usage credits in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (12)
WalkthroughReworks chat submission to support imperative submitForm(message?), removes artificial waits, streams resolution_search results with a Follow-up panel, adds server-side clearChat and server-derived current user ID, introduces tiered model selection, tightens UUID validation, and syncs map drawing context to the server. ChangesChat submission, resolution search, model tiering, and server auth
sequenceDiagram
participant User
participant UI as ChatPanel / Chat
participant Server as app/actions.tsx
participant Agent as resolutionSearch / Model
participant DB as lib/actions/chat.ts
User->>UI: submitForm(message?)
UI->>Server: POST /submit (FormData, input possibly from pendingMessageRef, mapData)
Server->>Agent: start resolutionSearch (tier-aware model via getModel)
Agent-->>Server: stream partial results
Server-->>UI: stream partial updates (append messages, FollowupPanel)
Agent->>Server: finalAnalysisResult
Server->>DB: saveChat / updateDrawingContext (validate userId)
Server-->>UI: final UI state (Follow-up section appended)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Review Summary by QodoImplement model tier system, eliminate submission race conditions, and optimize UI rendering
WalkthroughsDescription• Introduce 'auxiliary' model tier for lightweight tasks like query suggestions - Uses cheaper models (Claude 3 Haiku, Gemini 2.0 Flash Lite, GPT-4o Mini) - Applied to query suggestor for cost optimization • Eliminate race conditions in chat submission by refactoring message handling - Remove artificial 500ms delays from submission flow - Use ref-based message passing instead of state-based submission • Fix FollowupPanel action routing by removing hardcoded 'resolution_search' action • Improve UI rendering and performance - Center example prompts in EmptyScreen - Memoize SearchRelated component to prevent unnecessary re-renders - Fix key prop in related queries list - Relax related queries schema to accept 1-3 items instead of exactly 3 Diagramflowchart LR
A["getModel function"] -->|"tier parameter"| B["Primary vs Auxiliary models"]
B -->|"auxiliary tier"| C["Cheaper model variants"]
C -->|"used by"| D["Query Suggestor"]
E["Chat submission"] -->|"remove delays"| F["Ref-based message passing"]
F -->|"eliminate"| G["Race conditions"]
H["SearchRelated component"] -->|"memoize"| I["Performance optimization"]
J["Related queries schema"] -->|"relax validation"| K["Accept 1-3 items"]
File Changes1. lib/utils/index.ts
|
Code Review by Qodo
1. Followup drops mapProvider
|
|
@coderabbitai plan getSystemPrompt: Error: TypeError: Cannot read properties of undefined (reading 'searchParams') |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 6505 🏁 Script executed: Length of output: 24302
What’s happening
Recommended fix
Proposed diffs
import { NextResponse } from 'next/server'
import { getCurrentUserIdOnServer } from '@/lib/auth/get-current-user'
import { getSystemPrompt } from '@/lib/actions/chat'
export async function GET() {
try {
const userId = await getCurrentUserIdOnServer()
if (!userId) {
// If you want anonymous allowed, change to return a default/null instead of 401
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
}
const prompt = await getSystemPrompt(userId)
return NextResponse.json({ systemPrompt: prompt ?? '' })
} catch (err) {
console.error('GET /api/system-prompt failed:', err)
return NextResponse.json({ error: 'Internal Server Error' }, { status: 500 })
}
}
// remove: import { getSystemPrompt, saveSystemPrompt } from "../../../lib/actions/chat"
import { saveSystemPrompt } from "../../../lib/actions/chat"
// inside useEffect:
useEffect(() => {
let cancelled = false
async function load() {
if (!userId || authLoading) return
try {
const [promptRes, selectedModel] = await Promise.all([
fetch('/api/system-prompt', { cache: 'no-store' }).then(async r => {
if (!r.ok) return ''
const data = await r.json()
return (data?.systemPrompt as string) ?? ''
}),
getSelectedModel(),
])
if (!cancelled) {
form.setValue('systemPrompt', promptRes || defaultValues.systemPrompt!)
form.setValue('selectedModel', selectedModel || defaultValues.selectedModel!)
setIsLoading(false)
}
} catch (e) {
if (!cancelled) setIsLoading(false)
console.error('Failed to load settings:', e)
}
}
load()
return () => { cancelled = true }
}, [userId, authLoading, form])Notes
Would you like me to also:
If you want me to implement the API route + client change in this PR, I’ll prepare a concrete plan next.
The requested changes have been implemented and a pull request has been created: View PR |
I've addressed the 'searchParams' undefined error by explicitly awaiting |
- Explicitly await cookies() in get-current-user.ts for Next.js 15 - Update MOCK_USER_ID to a valid UUID format - Add UUID validation in lib/actions/chat.ts to prevent database errors - Handle null user IDs gracefully in app/actions.tsx Co-authored-by: ngoiyaeric <115367894+ngoiyaeric@users.noreply.github.com>
- Fix FollowupPanel action routing and direct message submission - Center example prompts and fix initial render flash - Introduce 'auxiliary' model tier for lightweight tasks - Optimize SearchRelated rendering with React.memo and stable keys - Fix Next.js 15 breaking changes (awaited cookies) - Add UUID validation and fix mock user ID format - Resolve all build-time type errors and compilation issues Co-authored-by: ngoiyaeric <115367894+ngoiyaeric@users.noreply.github.com>
|
@coderabbitai plan align left the example queries and the related section is not generating output as well as the regular query entries like the climate example query does not have a response but the resolution search is working better |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 19558 🏁 Script executed: Length of output: 11971 🏁 Script executed: Length of output: 4625
Issue 1 — Example queries are centered, not left-alignedThe PR changed Issue 2 — Regular queries (e.g. climate) show no responseRoot cause: Issue 3 — Related section renders but shows no itemsRoot cause: Task: Fix alignment + stream error handling
The requested changes have been implemented and a pull request has been created: View PR |
I've addressed your feedback:
|
- Restore left alignment for example prompts in EmptyScreen - Switch auxiliary Gemini model to gemini-1.5-flash for better stability - Add robust error handling in processEvents and querySuggestor - Fix Next.js 15 breaking changes (awaited cookies) - Add UUID validation and fix mock user ID format - Resolve all build-time type errors and confirm successful production build Co-authored-by: ngoiyaeric <115367894+ngoiyaeric@users.noreply.github.com>
PR created automatically by Jules for task 9467656735862578365 started by @ngoiyaeric
Summary by CodeRabbit
New Features
Improvements
Style