Skip to content

Add bad habit slip alert feature with AI notifications#5

Merged
thomasluizon merged 1 commit into
mainfrom
feature/slip-alert-notifications
Mar 20, 2026
Merged

Add bad habit slip alert feature with AI notifications#5
thomasluizon merged 1 commit into
mainfrom
feature/slip-alert-notifications

Conversation

@thomasluizon

Copy link
Copy Markdown
Owner

Summary

  • Detect day-of-week and time-of-day patterns in bad habit slip-up logs using SlipPatternDetectionService (60-day lookback, 3+ occurrences threshold)
  • Send AI-generated motivational push + bell notifications before predicted slip windows via SlipAlertSchedulerService (runs every 5 min)
  • Day-only patterns (e.g., always slips on Saturdays) trigger at 8 AM; time-aware patterns trigger 2h before peak hour
  • GeminiSlipAlertMessageService generates creative, varied, inspiring messages in the user's language (with static fallback)
  • Configurable per habit via slipAlertEnabled toggle, wired through full API layer
  • AI chat defaults slipAlertEnabled: true when creating bad habits
  • EF migration adds SlipAlertEnabled column + SentSlipAlerts table (weekly idempotency)

Test plan

  • dotnet test -- 160 unit tests pass, no regressions
  • Create bad habit via API with slipAlertEnabled: true, verify field persists in GET response
  • Verify SlipAlertSchedulerService started in logs on startup
  • AI chat: send "I want to stop smoking" -- verify created habit has slipAlertEnabled: true
  • Migration applies cleanly (dotnet ef database update)

🤖 Generated with Claude Code

Detect day-of-week and time-of-day patterns in bad habit slip-up logs
and send proactive AI-generated motivational push + bell notifications
before predicted slip windows. Configurable per habit via slipAlertEnabled
toggle. AI chat defaults slipAlertEnabled to true when creating bad habits.

- Add SlipAlertEnabled property to Habit entity (Create/Update)
- Add SentSlipAlert idempotency entity (1 alert/habit/week)
- Add SlipPatternDetectionService (60-day lookback, day+time patterns)
- Add SlipAlertSchedulerService (background, every 5 min)
- Add GeminiSlipAlertMessageService for AI-generated motivational messages
- Wire through API layer (commands, controller DTOs, query response)
- Update AI prompt with slipAlertEnabled schema and bad habit example
- Add EF migration for new column and table

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@thomasluizon
thomasluizon merged commit 28bb75f into main Mar 20, 2026
1 check passed
@thomasluizon
thomasluizon deleted the feature/slip-alert-notifications branch March 20, 2026 22:34
thomasluizon added a commit that referenced this pull request Apr 11, 2026
AI was making poor structuring decisions: creating 3 separate daily habits
for a single study routine, creating sub-habits for atomic gym prep steps,
and dropping shopping list items into the description with no checklist.

Root cause was missing guidance in the system prompt. The image flow had
hierarchy rules but the text flow had none, so the model guessed from scratch
every time.

- Add StructuringStrategySection (Order 250) teaching when to use checklist_items
  (atomic sub-steps, shopping lists, prep lists) vs sub_habits (independently
  trackable activities) vs separate parent habits, with concrete examples from
  the failure cases.
- Refine GlobalRules rule #5 to explicitly permit ONE targeted clarifying
  question when structure or schedule is ambiguous (days for weekly habits,
  unspecified time, checklist-vs-subhabit unclear).
- Tighten CreateHabitTool Description and the checklist_items/sub_habits
  schema descriptions so the model sees the distinction in the tool schema,
  not just the system prompt.

Tests: new StructuringStrategySectionTests, plus builder-level assertion that
the new section is wired in.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

1 participant