Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(upsell): remove duplicate notice dismissal on banner click

Steven Enamakel24d37e3fc2fb
diff --git a/app/src/components/notices/useAppNotices.ts b/app/src/components/notices/useAppNotices.ts
index 34a0451468..78c94ac713 100644
--- a/app/src/components/notices/useAppNotices.ts
+++ b/app/src/components/notices/useAppNotices.ts
@@ -29,6 +29,7 @@ import { selectActiveUserErrors } from '../../store/userErrorsSelectors';
import { dismissUserError, resolveUserError } from '../../store/userErrorsSlice';
import type { UserActionableError, UserErrorAction } from '../../types/userError';
import { applyOpenRouterFreeModels } from '../../services/api/openrouterFreeModels';
+import { dismissBanner, shouldShowBanner } from '../upsell/upsellDismissState';
import { PRICING_URL } from '../../utils/links';
import { openUrl } from '../../utils/openUrl';
@@ -81,6 +82,17 @@ const ACTION_LABEL_KEY: Record<Exclude<UserErrorAction, 'dismiss'>, string> = {
const SEVERITY_RANK: Record<NoticeSeverity, number> = { error: 0, warning: 1, info: 2 };
+/**
+ * How long a dismissed near-limit warning stays quiet.
+ *
+ * Carried over from the chat banner this notice replaced, which persisted its
+ * dismissal via `upsellDismissState`. The other derived notices use the
+ * in-memory set below, but usage creeps up over days — re-nagging on every
+ * restart is what the 24h cooldown was there to stop.
+ */
+const NEAR_LIMIT_COOLDOWN_MS = 24 * 60 * 60 * 1000;
+const NEAR_LIMIT_BANNER_ID = 'conversations-warning';
+
/** Highest severity present, or `null` for an empty list. */
export function peakSeverity(notices: readonly AppNotice[]): NoticeSeverity | null {
return notices.reduce<NoticeSeverity | null>(
@@ -198,7 +210,11 @@ export function useAppNotices(): AppNotice[] {
// ── Plan usage limit ───────────────────────────────────────────────
if (!usageLoading && teamUsage) {
const upsellId = isAtLimit ? 'usage:at-limit' : 'usage:near-limit';
- const show = isAtLimit || (isNearLimit && isFreeTier);
+ const show = isAtLimit
+ ? true
+ : isNearLimit &&
+ isFreeTier &&
+ shouldShowBanner(NEAR_LIMIT_BANNER_ID, NEAR_LIMIT_COOLDOWN_MS);
if (show && !dismissed.has(upsellId)) {
notices.push({
id: upsellId,
@@ -214,7 +230,14 @@ export function useAppNotices(): AppNotice[] {
onAction: () => void openUrl(PRICING_URL),
// At the limit the app is already gated, so silencing it would hide
// the only explanation of why nothing works.
- ...(isAtLimit ? {} : { onDismiss: () => dismiss(upsellId) }),
+ ...(isAtLimit
+ ? {}
+ : {
+ onDismiss: () => {
+ dismissBanner(NEAR_LIMIT_BANNER_ID);
+ dismiss(upsellId);
+ },
+ }),
});
}
}
diff --git a/app/src/components/upsell/UpsellBanner.tsx b/app/src/components/upsell/UpsellBanner.tsx
deleted file mode 100644
index 4640bd46d4..0000000000
--- a/app/src/components/upsell/UpsellBanner.tsx
+++ /dev/null
@@ -1,98 +0,0 @@
-import { useT } from '../../lib/i18n/I18nContext';
-
-interface UpsellBannerProps {
- variant: 'info' | 'warning' | 'upgrade';
- title: string;
- message: string;
- ctaLabel?: string;
- onCtaClick?: () => void;
- dismissible?: boolean;
- rounded?: boolean;
- onDismiss?: () => void;
-}
-
-const VARIANT_STYLES = {
- info: {
- container: 'bg-blue-50 dark:bg-blue-500/15 border-blue-200 dark:border-blue-800',
- icon: 'text-blue-400',
- title: 'text-blue-700 dark:text-blue-300',
- text: 'text-blue-600 dark:text-blue-300',
- cta: 'bg-blue-500 hover:bg-blue-400 text-white',
- },
- warning: {
- container: 'bg-amber-50 dark:bg-amber-500/15 border-amber-200 dark:border-amber-800',
- icon: 'text-amber-400',
- title: 'text-amber-700 dark:text-amber-300',
- text: 'text-amber-600 dark:text-amber-300',
- cta: 'bg-amber-500 hover:bg-amber-400 text-content-inverted',
- },
- upgrade: {
- container: 'bg-amber-50 dark:bg-amber-500/15 border-amber-200 dark:border-amber-800',
- icon: 'text-amber-400',
- title: 'text-amber-700 dark:text-amber-300',
- text: 'text-amber-600 dark:text-amber-300',
- cta: 'bg-amber-500 hover:bg-amber-400 text-content-inverted',
- },
-};
-
-export default function UpsellBanner({
- variant,
- title,
- message,
- ctaLabel,
- onCtaClick,
- dismissible,
- onDismiss,
- rounded = true,
-}: UpsellBannerProps) {
- const { t } = useT();
- const styles = VARIANT_STYLES[variant];
-
- return (
- <div
- className={`p-3 ${rounded ? 'rounded-xl' : ''} border flex items-center justify-between gap-3 ${styles.container}`}>
- <div className="flex items-center gap-2 min-w-0">
- <svg
- className={`w-4 h-4 shrink-0 ${styles.icon}`}
- fill="none"
- stroke="currentColor"
- viewBox="0 0 24 24">
- <path
- strokeLinecap="round"
- strokeLinejoin="round"
- strokeWidth={2}
- d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
- />
- </svg>
- <div className="min-w-0">
- <p className={`text-xs font-medium ${styles.title}`}>{title}</p>
- <p className={`text-xs ${styles.text} truncate`}>{message}</p>
- </div>
- </div>
- <div className="flex items-center gap-2 shrink-0">
- {ctaLabel && onCtaClick && (
- <button
- onClick={onCtaClick}
- className={`px-3 py-1.5 rounded-lg text-xs font-medium transition-colors ${styles.cta}`}>
- {ctaLabel}
- </button>
- )}
- {dismissible && onDismiss && (
- <button
- onClick={onDismiss}
- className="p-1 rounded text-content-faint hover:text-content-secondary transition-colors"
- aria-label={t('common.dismiss')}>
- <svg className="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path
- strokeLinecap="round"
- strokeLinejoin="round"
- strokeWidth={2}
- d="M6 18L18 6M6 6l12 12"
- />
- </svg>
- </button>
- )}
- </div>
- </div>
- );
-}