Skip to content

feat: enrich AI user context with entry count, streak, and word count #22

Description

@TrainTravel

Context

All three edge functions (reflection, french-feedback, french-chat) currently receive lang to build a dynamic USER CONTEXT block. The next step is to also pass per-user stats so the model can calibrate its responses more precisely.

What to pass from the frontend

userContext: {
  totalEntries: totalDays,   // from useJournal()
  totalWords,                // from useJournal()
  streak,                    // from useJournal()
  lang,                      // already wired
}

What to do in the edge functions

const level = totalEntries < 5 ? 'complete beginner'
            : totalEntries < 20 ? 'early learner'
            : 'developing learner';

// Inject into USER CONTEXT block:
// - French level: ${level} (${totalEntries} journal entries)
// - Total words written: ${totalWords}
// - Current streak: ${streak} days

Files to change

  • src/components/journal/ReflectionScreen.tsx
  • src/components/journal/FeedbackScreen.tsx
  • src/components/journal/ChatScreen.tsx
  • supabase/functions/reflection/index.ts
  • supabase/functions/french-feedback/index.ts
  • supabase/functions/french-chat/index.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions