diff --git a/cloud/emails.py b/cloud/emails.py
index 540dde8..99fca08 100644
--- a/cloud/emails.py
+++ b/cloud/emails.py
@@ -79,6 +79,36 @@ async def send_clips_ready_email(email: str, job_title: str, clip_count: int,
await send_email(email, f"Your clips are ready — {title}", html)
+async def send_clips_expiring_email(email: str, clip_count: int):
+ """Free clips enter their last day before deletion — honest loss aversion.
+
+ The deadline is real (FREE_CLIP_RETENTION_DAYS); this simply makes it
+ visible instead of deleting silently. Doubles as re-engagement for users
+ who clipped once and went quiet.
+ """
+ dash = f"{settings.frontend_url}/dashboard"
+ n = clip_count
+ clips = f"{n} clip" + ("s" if n != 1 else "")
+ html = f"""
+
+
Your {clips} will be deleted tomorrow ⏳
+
Free clips are stored for 7 days, and {('these' if n != 1 else 'this one')}
+ {'are' if n != 1 else 'is'} about to expire. Two ways to keep them:
+
+
Download them now from your dashboard, or
+
Upgrade to Starter ($12/mo) — clips stored forever,
+ no watermark, and 100 minutes every month.
After tomorrow they're gone for good
+ — we can't recover deleted clips.
+
+ """
+ print(f"⏳ Clips-expiring email → {email} ({clips})")
+ await send_email(email, f"Your {clips} will be deleted tomorrow", html)
+
+
async def send_out_of_minutes_email(email: str, upgrade_url: str):
"""Free user hit their monthly quota — the natural upgrade moment.
diff --git a/cloud/videos.py b/cloud/videos.py
index 9ff0ef3..f28e2eb 100644
--- a/cloud/videos.py
+++ b/cloud/videos.py
@@ -11,7 +11,7 @@ from sqlalchemy import select, delete
from .config import settings, VIDEO_RETENTION_GRACE_DAYS, FREE_CLIP_RETENTION_DAYS
from . import database, storage, metering
-from .models import UserVideo, Subscription, Project
+from .models import UserVideo, Subscription, Project, User
from .auth import get_current_user_required
router = APIRouter()
@@ -333,6 +333,52 @@ async def purge_free_expired():
print(f"⚠️ Free retention purge failed for {user_id}: {e}")
+# Video ids already covered by an expiry-warning email, so the 6-hourly sweep
+# doesn't re-mail the same user four times during the warning window. Process
+# memory only: after a restart the worst case is one duplicate warning.
+_warned_video_ids: set = set()
+
+
+async def warn_free_expiring():
+ """Email free users whose clips enter their LAST day before deletion.
+
+ The 7-day free retention is the plan's strongest honest upgrade lever, but
+ silently deleting clips converts nobody — the user never learns they were
+ at risk. One email on day 6 turns the real deadline into a visible one.
+ """
+ from datetime import datetime, timezone
+ from .emails import send_clips_expiring_email
+ now = datetime.now(timezone.utc)
+ doomed_after = now - timedelta(days=FREE_CLIP_RETENTION_DAYS) # already purgeable
+ warn_cutoff = now - timedelta(days=FREE_CLIP_RETENTION_DAYS - 1) # < 1 day left
+
+ async with database.session() as s:
+ expiring = list((await s.execute(
+ select(UserVideo).where(UserVideo.created_at < warn_cutoff,
+ UserVideo.created_at >= doomed_after)
+ )).scalars())
+
+ by_user = {}
+ for v in expiring:
+ if v.id in _warned_video_ids:
+ continue
+ by_user.setdefault(v.user_id, []).append(v)
+
+ for user_id, vids in by_user.items():
+ async with database.session() as s:
+ if not await metering.is_free_user(s, user_id):
+ continue
+ user = await s.get(User, user_id)
+ if not user or not user.email:
+ continue
+ try:
+ await send_clips_expiring_email(user.email, len(vids))
+ _warned_video_ids.update(v.id for v in vids)
+ print(f"⏳ Expiry warning sent: {len(vids)} clip(s), user {user_id}")
+ except Exception as e:
+ print(f"⚠️ Expiry warning failed for {user_id}: {e}")
+
+
_SWEEP_INTERVAL = 6 * 3600 # every 6 hours
@@ -340,6 +386,7 @@ async def _sweeper_loop():
while True:
try:
await asyncio.sleep(_SWEEP_INTERVAL)
+ await warn_free_expiring()
await purge_expired()
await purge_free_expired()
except asyncio.CancelledError:
diff --git a/dashboard/src/App.jsx b/dashboard/src/App.jsx
index 8750fc2..33ffdd7 100644
--- a/dashboard/src/App.jsx
+++ b/dashboard/src/App.jsx
@@ -780,9 +780,14 @@ function App() {
/>
)}
- {/* Cloud: minutes meter + account/sign-in */}
+ {/* Cloud: minutes meter + account/sign-in. For free users the meter
+ opens the upgrade modal — otherwise the only path to a plan is
+ failing against the quota wall. */}
{billingEnabled && isManaged && (
- { window.location.hash = '#/account'; }} />
+ {
+ if (plan === 'free') { setTopUpInfo({ context: 'upsell' }); setShowTopUp(true); }
+ else { window.location.hash = '#/account'; }
+ }} />
)}
{billingEnabled && isSignedIn && !isManaged && (