Skip to content

feat(#1466 P2): automation-gate nudge + "I've got this" toggle + calendar fix#1470

Merged
Systemsaholic merged 1 commit into
mainfrom
feature/issue-1466-p2-nudge
Jul 5, 2026
Merged

feat(#1466 P2): automation-gate nudge + "I've got this" toggle + calendar fix#1470
Systemsaholic merged 1 commit into
mainfrom
feature/issue-1466-p2-nudge

Conversation

@Systemsaholic

Copy link
Copy Markdown
Owner

Automation Gate epic #1466 — slice P2 (escalation/nudge + toggle)

refs #1466. Builds on merged P0 (reliability) + P1 (proposed status + gate). INTERNAL-ONLY — advisor bell/email notifications, no client sends. Autopilot-default; ships LIVE on merge. Additive/no-backfill, no migration (the notification dedupe index is the "already nudged" state).

What ships

  1. Courtesy nudge — new hourly recurring job recurring.automation_gate_nudge (sibling of recurring.task_due_reminder on the CLIENT_CARE queue). Each sweep:
    • queries automation_job_history for status IN ('proposed','paused') with scheduled_for in (now, now+24h],
    • groups by trip_id, resolves the advisor as the trip owner (automation rows carry no created_by),
    • sends one internal automation_gate notification per trip with actionUrl:/trips/{id}?tab=automations and an advisor-scoped, UTC-day-bucketed dedupeKey (automation-gate:{advisorId}:{tripId}:{bucket}).
    • The platform dedupe index is global on dedupe_key, so the advisor id is embedded → exactly one nudge/trip/day, no cross-advisor collision. Per-trip try/catch keeps the sweep best-effort.
    • Also fixes the "paused-forever silence": a paused row nearing its original time is surfaced by the same sweep.
    • Pure window/grouping + key logic lives in automation-gate-nudge.ts (unit-tested, DB-free).
  2. "I've got this" toggle — pure UI sugar over existing pause/resume (zero new backend). The Pause button now also renders on proposed (autopilot) cards and reads "I've got this"; Resume reads "Back to autopilot". isControllable + the backend pause path already accept proposed (P1).
  3. Calendar fix (P1 handoff) — the scheduled-email query widened from status='queued' to include 'proposed', so gate jobs (which are BullMQ-live) appear on the calendar before review instead of being invisible.

New notification category automation_gate (default channels [platform, email]) wired across notification.types.ts, notification.service.ts, @tailfire/shared-types, the preferences schema, and the profile settings UI.

Tests

  • automation-gate-nudge.spec.ts — pure query/grouping (window bounds, gate-status filter, grouping, deterministic ordering) + dedupeKey-embeds-advisorId + copy.
  • client-care.processor.automation-gate-nudge.spec.ts — integration: sends internal automation_gate nudge to the trip owner; 2nd sweep same UTC day does NOT re-notify (dedupe holds); skips owner-less trips.
  • All related existing API suites green (automation.service, automation.types, calendar scheduled-email, notification.service = 82 passed); admin automation-grouping (20) + admin typecheck clean.

Review

  • Codex (gpt-5.5, xhigh) APPROVE on exact HEAD 156fe45d — verified dedupe correctness, no client-send path, best-effort handling, and that the toggle/calendar changes don't regress queued behavior. Two non-blocking nits from the first pass (UI default parity + a stale comment) were addressed and re-approved.

🤖 Generated with Claude Code

…ndar fix

Escalation/nudge + toggle slice of the Automation Gate epic (internal-only —
advisor bell/email, no client sends). Builds on P1's `proposed` status + gate.

- Courtesy nudge: hourly `recurring.automation_gate_nudge` (sibling of
  task_due_reminder) sweeps automation_job_history for proposed/paused rows
  firing within 24h, groups by trip, resolves the advisor (trip owner), and
  sends a new internal `automation_gate` notification with an advisor-scoped
  day-bucketed dedupeKey (one nudge/trip/day via the global dedupe claim).
  Also breaks the "paused-forever silence" — a parked row nearing its time
  gets the same nudge. Pure query/grouping + key logic in automation-gate-nudge.ts.
- "I've got this" toggle: UI sugar over existing pause/resume — Pause now
  renders on proposed (autopilot) cards too and relabels to "I've got this";
  Resume relabels to "Back to autopilot". Zero new backend.
- Calendar fix (P1 handoff): scheduled-email query widened from status='queued'
  to include 'proposed' so gate jobs surface on the calendar before review.

New notification category `automation_gate` (platform + email default),
registered across notification.types, shared-types, and the preferences schema/UI.
No migration (dedupe index = "already nudged").

Tests: pure query/grouping + dedupeKey-embeds-advisorId spec; processor
integration proving a 2nd sweep same UTC day does not re-notify.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 5, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
tailfire-client Ready Ready Preview, Comment Jul 5, 2026 9:46am
tailfire-ota Ready Ready Preview, Comment Jul 5, 2026 9:46am

Request Review

@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Systemsaholic, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 6 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b1db24c7-c956-4adb-99d7-1cffccad3502

📥 Commits

Reviewing files that changed from the base of the PR and between b4d22e2 and 156fe45.

📒 Files selected for processing (13)
  • apps/admin/src/app/profile/_components/notifications-tab.tsx
  • apps/admin/src/app/trips/[id]/_components/automation-job-card.tsx
  • apps/api/src/automation/automation-gate-nudge.spec.ts
  • apps/api/src/automation/automation-gate-nudge.ts
  • apps/api/src/automation/automation.service.ts
  • apps/api/src/automation/automation.types.ts
  • apps/api/src/automation/processors/client-care.processor.automation-gate-nudge.spec.ts
  • apps/api/src/automation/processors/client-care.processor.ts
  • apps/api/src/calendar/calendar.service.ts
  • apps/api/src/notifications/notification.service.ts
  • apps/api/src/notifications/notification.types.ts
  • packages/database/src/schema/notification-preferences.schema.ts
  • packages/shared-types/src/api/notifications.types.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/issue-1466-p2-nudge

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.

❤️ Share

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

@Systemsaholic Systemsaholic merged commit 5d345b4 into main Jul 5, 2026
13 of 19 checks passed
@Systemsaholic Systemsaholic deleted the feature/issue-1466-p2-nudge branch July 5, 2026 09:50
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