From 6d3498c91b7bf327e58ff69087c50de7025258ac Mon Sep 17 00:00:00 2001 From: Felarof Date: Thu, 16 Apr 2026 17:09:28 -0700 Subject: [PATCH] fix: randomized tweet variations + referral fixes (#737) * fix(agent): declare @browseros/shared as workspace dependency The agent app imports @browseros/shared/constants/urls in lib/referral/submit-referral.ts but never declared the package in its dependencies, so vite failed to resolve the import during dev. Co-Authored-By: Claude Opus 4.7 (1M context) * feat(referral): cap daily referral earnings at 500 credits Block tweet submissions client-side once the user's balance reaches 500 to prevent unlimited credit farming via repeated shares. Co-Authored-By: Claude Opus 4.7 (1M context) * feat(referral): randomize tweet variations for Twitter share Replace the single hardcoded share text with 10 feature-specific variations (agent mode, chat, scheduled tasks, connect apps, cowork, workflows, memory, skills, local models, ad blocking) and pick one at random each time the share button is clicked. Co-Authored-By: Claude Opus 4.7 (1M context) * fix(referral): regenerate share URL on click Previously getShareOnTwitterUrl() was evaluated once at render time as a static href, so every click produced the same tweet variation. Move the call into onClick so a new random variation is picked each time. Addresses Greptile P1 review on PR #737. Co-Authored-By: Claude Opus 4.7 (1M context) --------- Co-authored-by: Claude Opus 4.7 (1M context) --- .../components/referral/ShareForCredits.tsx | 27 ++++++- .../agent/lib/referral/submit-referral.ts | 77 ++++++++++++++++++- .../browseros-agent/apps/agent/package.json | 1 + packages/browseros-agent/bun.lock | 3 +- .../packages/shared/src/constants/limits.ts | 5 ++ 5 files changed, 109 insertions(+), 4 deletions(-) diff --git a/packages/browseros-agent/apps/agent/components/referral/ShareForCredits.tsx b/packages/browseros-agent/apps/agent/components/referral/ShareForCredits.tsx index c5841c381..946d76659 100644 --- a/packages/browseros-agent/apps/agent/components/referral/ShareForCredits.tsx +++ b/packages/browseros-agent/apps/agent/components/referral/ShareForCredits.tsx @@ -1,3 +1,4 @@ +import { REFERRAL_LIMITS } from '@browseros/shared/constants/limits' import { ExternalLink, Loader2, Send } from 'lucide-react' import type { FC } from 'react' import { useState } from 'react' @@ -24,8 +25,11 @@ export const ShareForCredits: FC = ({ compact }) => { const { data } = useCredits() const invalidateCredits = useInvalidateCredits() + const credits = data?.credits ?? 0 + const atDailyMax = credits >= REFERRAL_LIMITS.MAX_DAILY_CREDITS + const handleSubmit = async () => { - if (!tweetUrl.trim() || !data?.browserosId) return + if (!tweetUrl.trim() || !data?.browserosId || atDailyMax) return setIsSubmitting(true) setResult(null) @@ -55,10 +59,22 @@ export const ShareForCredits: FC = ({ compact }) => { } } + if (atDailyMax) { + return ( +
+

+ You've reached the daily cap of {REFERRAL_LIMITS.MAX_DAILY_CREDITS}{' '} + credits. Come back tomorrow to earn more! +

+
+ ) + } + return (

- Share BrowserOS on Twitter to earn 200 bonus credits! + Share BrowserOS on Twitter to earn{' '} + {REFERRAL_LIMITS.CREDITS_PER_REFERRAL} bonus credits!

    @@ -67,6 +83,10 @@ export const ShareForCredits: FC = ({ compact }) => {
  • Tweet must be posted within the last 30 minutes
  • Each tweet can only be submitted once
  • +
  • + Daily cap of {REFERRAL_LIMITS.MAX_DAILY_CREDITS} credits — resets at + midnight UTC +