Skip to content

Conversation

@rossmanko
Copy link
Contributor

@rossmanko rossmanko commented Dec 7, 2025

Summary by CodeRabbit

  • New Features

    • Added mode reminder guidance for paid subscribers in ASK MODE, explaining available tools and when to switch to AGENT MODE.
  • Chores

    • Updated AI model configurations and analytics initialization logic.
    • Minor formatting adjustments to internal scripts.

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link

vercel bot commented Dec 7, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
hackerai Ready Ready Preview Comment Dec 7, 2025 8:32pm

@coderabbitai
Copy link

coderabbitai bot commented Dec 7, 2025

Walkthrough

The PR updates AI model provider mappings to use Grok models, adds subscription-based guards to prevent free-tier analytics tracing, unconditionally initializes PostHogClient, and extends the system prompt to include mode reminders for paid subscribers.

Changes

Cohort / File(s) Summary
Provider & Model Configuration
lib/ai/providers.ts
Updated model mappings: "title-generator-model" and "summarization-model" now use xai Grok models instead of previous targets. Added subscription guard in createTrackedProvider to skip tracing for free-tier users in addition to when PostHog client is absent.
Analytics Initialization
lib/api/chat-handler.ts
Changed PostHogClient initialization from conditional (only when subscription ≠ "free") to unconditional, simplifying code flow and ensuring consistent initialization.
System Prompt Enhancement
lib/system-prompt.ts
Extended getAskModeSection to accept subscription parameter and inject mode reminder block into ASK MODE prompt for non-free tiers, guiding users on tool limitations and mode switching.
Script Formatting
scripts/attach-failing-card.ts
Minor console output formatting: wrapped multi-line log statements with improved indentation (no behavioral changes).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–25 minutes

  • lib/ai/providers.ts: Verify model mappings are correct for intended use cases; ensure the new subscription guard in createTrackedProvider aligns with free-tier analytics strategy across the codebase.
  • lib/api/chat-handler.ts: Confirm PostHogClient unconditional initialization doesn't break existing null-coalescing guards or introduce unintended side effects.
  • lib/system-prompt.ts: Validate subscription parameter threading throughout call chain and confirm prompt injection logic doesn't inadvertently alter system behavior for other subscription tiers.

Possibly related PRs

  • Daily branch 2025 09 21 #35, #45, #65, #61: All directly modify lib/ai/providers.ts baseProviders mappings, creating potential merge conflicts or duplicate model configuration logic.
  • Daily branch 2025 09 23 #37: Modifies subscription/entitlement derivation logic; directly impacts the new subscription-based guards introduced in this PR (createTrackedProvider and prompt behavior).

Poem

🐰 Grok models now fly, free users stay silent,
PostHog flows steady, analytics compliant.
Prompts whisper reminders of modes yet untried,
A humble refactor—where logic and love coincide! 🚀

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title 'Daily branch 2025 12 06' is vague and generic, using only a date reference without describing the actual changes (model provider updates, free subscription handling, system prompt modifications). Replace with a descriptive title summarizing the main changes, such as 'Switch to Grok models and add free subscription checks' or 'Update AI providers and add free tier handling'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch daily-branch-2025-12-06

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
lib/api/chat-handler.ts (1)

161-163: Unconditional PostHog initialization is OK; consider also gating manual capture for free tier

Calling PostHogClient() unconditionally here is fine; createTrackedProvider now cleanly falls back to myProvider when phClient is null or subscription === "free", so provider-level tracing is disabled for free users while keeping the call site simple.

However, onChunk still does:

if (posthog) {
  posthog.capture({ distinctId: userId, ... });
}

so free-tier ASK sessions will still emit tool-call events to PostHog when the client is configured. If the goal is to avoid all analytics for free users (not just model tracing), you may want to add a subscription !== "free" check around that block as well.

lib/system-prompt.ts (1)

165-180: ASK-mode prompt changes look good; minor type reuse nit

The new modeReminder for non-free subscriptions correctly explains ASK MODE’s limited tools and when to switch to AGENT MODE, while omitting that block for free users so you don’t advertise a mode they can’t access. The updated call site passing subscription into getAskModeSection is consistent.

Optionally, you could reuse a shared SubscriptionTier type here instead of repeating the union literal to avoid drift if tiers change.

Also applies to: 299-300

lib/ai/providers.ts (1)

17-18: Provider and tracing updates make sense; double-check summarization cutoff

Pointing both "title-generator-model" and "summarization-model" at xai("grok-4-1-fast-non-reasoning") is consistent, and the new guard:

if (!phClient || subscription === "free") {
  return myProvider;
}

nicely ensures PostHog tracing is only enabled when a client exists and the user is non-free, falling back cleanly otherwise.

Given both models now share the same underlying provider, consider whether "summarization-model"’s modelCutoffDates entry should also be bumped to match "title-generator-model" for consistency, unless there’s a deliberate reason to keep it at "November 2024".

Also applies to: 48-50

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1537203 and 738266a.

📒 Files selected for processing (4)
  • lib/ai/providers.ts (2 hunks)
  • lib/api/chat-handler.ts (1 hunks)
  • lib/system-prompt.ts (2 hunks)
  • scripts/attach-failing-card.ts (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
lib/system-prompt.ts (1)
lib/ai/providers.ts (2)
  • ModelName (21-21)
  • getModelCutoffDate (34-36)
lib/api/chat-handler.ts (1)
app/posthog.js (1)
  • PostHogClient (3-17)
🔇 Additional comments (1)
scripts/attach-failing-card.ts (1)

75-79: Console log reformatting is fine

These are pure formatting changes to long console.log calls; no behavior change and the wrapped style is clear and consistent.

Also applies to: 82-84, 104-106, 118-120

@rossmanko rossmanko merged commit 9ece5d3 into main Dec 7, 2025
4 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Jan 12, 2026
@coderabbitai coderabbitai bot mentioned this pull request Jan 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants