Polish composer and Tavily research flow#108
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b818a102c4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| await recordUsageLedgerEvent({ | ||
| userId: authorId, | ||
| eventType: 'web_search', |
There was a problem hiding this comment.
Update ledger schema for new web_search event type
generateAnswerForPrompt now inserts eventType: 'web_search', but the checked-in DB schema still restricts usage_ledger.event_type to chat_generation, credit_blocked, and upload (see supabase/migrations/20260514110000_create_usage_ledger.sql). In environments created from these migrations, every successful research request will hit a check-constraint error and the event will be dropped, leaving web-search analytics/accounting incomplete.
Useful? React with 👍 / 👎.
| } catch (error) { | ||
| console.error('[tavily_search_failed]', { userId: authorId, error }) |
There was a problem hiding this comment.
Return a user-visible error when Tavily research fails
If Tavily search fails (e.g., missing/invalid TAVILY_API_KEY or provider outage), this block only logs and then continues generation with researchMode still on but no research context. That produces responses presented as Deep Research without the promised web grounding/citations, which is an accuracy regression specific to research-mode requests under Tavily failure conditions.
Useful? React with 👍 / 👎.
| limits: { | ||
| messagesPerDay: 'unlimited', | ||
| fileUploadsPerDay: 3, | ||
| webSearchesPerMonth: 5, |
There was a problem hiding this comment.
Align free web-search quota with research access checks
The free plan now advertises webSearchesPerMonth: 5, but generation still hard-blocks research mode for non-Pro/Plus users (lib/generate-answer.ts, the existing researchMode plan gate). That makes the new free quota unreachable in practice and creates a user-facing mismatch between plan limits/profile messaging and actual behavior.
Useful? React with 👍 / 👎.
| if (now >= resetAt) { | ||
| updates.monthly_web_searches = 0 | ||
| const nextSearchResetDate = new Date(now) | ||
| nextSearchResetDate.setMonth(nextSearchResetDate.getMonth() + 1) |
There was a problem hiding this comment.
Clamp monthly reset date to avoid month-end overflow
Using setMonth(getMonth() + 1) on a late-month date can skip into the following month (for example, Jan 31 becomes Mar 3 in JavaScript), so users can be locked out longer than one month before monthly_web_searches resets. This directly affects quota enforcement for users whose reset is computed near month end.
Useful? React with 👍 / 👎.
Summary\n- Move prompt selections into the composer surface so active options show inline\n- Wire Deep Research to Tavily-backed web search with plan limits\n- Clean up blockchain lab wallet creation and supporting API routes\n- Remove SEARXNG references from source/config\n- Tighten the dark UI and sidebar interactions\n\n## Verification\n- pnpm exec tsc --noEmit