The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
feat(memory): disable the built-in engine on a plan without memory; e2e for #8081
M3gA-Mind6e9e78742062
diff --git a/app/scripts/e2e-run-all-flows.sh b/app/scripts/e2e-run-all-flows.shindex 433a080468..dd717667f8 100755--- a/app/scripts/e2e-run-all-flows.sh+++ b/app/scripts/e2e-run-all-flows.sh@@ -404,6 +404,7 @@ if should_run_suite "settings"; thenecho "## Running suite: settings"run "test/e2e/specs/settings-channels-permissions.spec.ts" "settings-channels" "settings"run "test/e2e/specs/settings-data-management.spec.ts" "settings-data" "settings"+ run "test/e2e/specs/memory-plan-required.spec.ts" "memory-plan-required" "settings"run "test/e2e/specs/settings-ai-skills.spec.ts" "settings-ai-skills" "settings"run "test/e2e/specs/settings-account-preferences.spec.ts" "settings-account" "settings"run "test/e2e/specs/settings-advanced-config.spec.ts" "settings-advanced" "settings"diff --git a/app/src/components/memory/MemoryConnectionPanel.tsx b/app/src/components/memory/MemoryConnectionPanel.tsxindex ad95e5358a..8dc386fe67 100644--- a/app/src/components/memory/MemoryConnectionPanel.tsx+++ b/app/src/components/memory/MemoryConnectionPanel.tsx@@ -1,5 +1,6 @@import { ExternalLink, Info } from 'lucide-react';import { type ReactNode, useId } from 'react';+import { useNavigate } from 'react-router-dom';import { useT } from '../../lib/i18n/I18nContext';import { type EngineState, isMemoryOn } from '../../services/api/memoryApi';@@ -7,6 +8,7 @@ import { TINYHUMANS_TERMS_URL } from '../../utils/links';import { openUrl } from '../../utils/openUrl';import { Alert, AlertDescription, Button, Label, TextField } from '../ui';import { PopoverContent, PopoverRoot, PopoverTrigger } from '../ui/Popover';+import { BILLING_ROUTE, MEMORY_QUOTA, planIncludesMemory } from './memoryPlan';import type { MemoryProviderOption } from './MemoryProviderLogo';/** CortexDB's self-hosting guide, linked from the Local provider. */@@ -62,9 +64,6 @@ export interface MemoryConnectionPanelProps {onSubmit: () => void;}-/** Free hosted memory per plan; memory inference itself is never charged. */-const MEMORY_QUOTA = { BASIC: '1 GB', PRO: '20 GB' } as const;-/*** One way to connect CortexDB, shown under its chip on Memory → Provider: what* it is, what it needs (nothing via TinyHumans, a key for your own account, an@@ -95,7 +94,11 @@ export default function MemoryConnectionPanel({const baseId = useId();const formId = `${baseId}-form`;const busy = saving !== null;+ const navigate = useNavigate();const planName = plan === 'PRO' ? 'Pro' : plan === 'BASIC' ? 'Basic' : null;+ // A known plan without memory (FREE): "Use" is disabled by the caller and+ // this says why. An unknown plan is left to the core's PLAN_REQUIRED.+ const planWithoutMemory = plan !== null && !planIncludesMemory(plan);const keyField = (value: string, onChange: (value: string) => void) => {const saved = active && state.has_key;@@ -187,6 +190,21 @@ export default function MemoryConnectionPanel({{t('memoryPage.engine.builtin.signInHint')}</p>)}+ {signedIn && planWithoutMemory && (+ <Alert variant="warning" data-testid="memory-engine-builtin-plan-required">+ <AlertDescription className="flex flex-wrap items-center gap-2">+ <span>{t('memoryPage.engine.builtin.planRequired')}</span>+ <Button+ type="button"+ size="xs"+ variant="primary"+ data-testid="memory-engine-builtin-upgrade"+ onClick={() => navigate(BILLING_ROUTE)}>+ {t('memory.planRequired.action')}+ </Button>+ </AlertDescription>+ </Alert>+ )}</>);diff --git a/app/src/components/memory/MemoryEngineTab.test.tsx b/app/src/components/memory/MemoryEngineTab.test.tsxindex 42cc814fbf..29677a2186 100644--- a/app/src/components/memory/MemoryEngineTab.test.tsx+++ b/app/src/components/memory/MemoryEngineTab.test.tsx@@ -247,6 +247,31 @@ describe('MemoryEngineTab', () => {expect(hoisted.openUrl).toHaveBeenCalledWith('https://tinyhumans.ai/terms');});+ it('disables Use on a FREE plan and points to an upgrade (#8081)', () => {+ hoisted.plan = 'FREE';+ renderTab(OFF);+ const panel = pick('builtin');+ expect(within(panel).getByTestId('memory-engine-builtin-submit')).toBeDisabled();+ expect(within(panel).getByTestId('memory-engine-builtin-plan-required')).toHaveTextContent(+ "Your plan doesn't include memory hosted by TinyHumans."+ );+ fireEvent.click(within(panel).getByTestId('memory-engine-builtin-submit'));+ expect(hoisted.engineSet).not.toHaveBeenCalled();+ expect(within(panel).getByTestId('memory-engine-builtin-upgrade')).toHaveTextContent(+ 'Upgrade'+ );+ });++ it.each([['BASIC'], ['PRO'], [null]])('keeps Use enabled on plan %s', plan => {+ hoisted.plan = plan;+ renderTab(OFF);+ const panel = pick('builtin');+ expect(within(panel).getByTestId('memory-engine-builtin-submit')).toBeEnabled();+ expect(+ within(panel).queryByTestId('memory-engine-builtin-plan-required')+ ).not.toBeInTheDocument();+ });+it('gives the Basic plan 1 GB of memory', () => {hoisted.plan = 'BASIC';renderTab(BUILTIN_ON);diff --git a/app/src/components/memory/MemoryEngineTab.tsx b/app/src/components/memory/MemoryEngineTab.tsxindex f72d4eab9e..159938961d 100644--- a/app/src/components/memory/MemoryEngineTab.tsx+++ b/app/src/components/memory/MemoryEngineTab.tsx@@ -51,6 +51,7 @@ import MemoryConnectionPanel from './MemoryConnectionPanel';import MemoryCortexAnnouncement from './MemoryCortexAnnouncement';import MemoryCortexCard from './MemoryCortexCard';import MemoryDisabledCard from './MemoryDisabledCard';+import { planIncludesMemory } from './memoryPlan';import MemoryProviderLogo, { type MemoryProviderOption } from './MemoryProviderLogo';export { CORTEXDB_SELF_HOST_DOCS_URL } from './MemoryConnectionPanel';@@ -302,7 +303,7 @@ export default function MemoryEngineTab({ state, onStateChange, embedded }: MemoonLocalKey={setLocalKey}canSubmit={option === 'builtin'- ? saving === null && signedIn+ ? saving === null && signedIn && (plan === null || planIncludesMemory(plan)): option === 'apikey'? canSubmitCloud: canSubmitLocaldiff --git a/app/src/components/memory/MemoryErrorAlert.tsx b/app/src/components/memory/MemoryErrorAlert.tsxindex 702d2ab46c..5f68f3fda9 100644--- a/app/src/components/memory/MemoryErrorAlert.tsx+++ b/app/src/components/memory/MemoryErrorAlert.tsx@@ -10,9 +10,7 @@ import { useNavigate } from 'react-router-dom';import { useT } from '../../lib/i18n/I18nContext';import { isOutOfCreditsMessage, isPlanRequiredMessage } from '../../services/api/memoryApi';import { Alert, AlertDescription, AlertTitle, Button } from '../ui';--/** Where the app sends every "top up" action (`open_billing` in useAppNotices). */-const BILLING_ROUTE = '/settings/account';+import { BILLING_ROUTE } from './memoryPlan';interface MemoryCreditsPromptProps {/** The out-of-credits explanation. */diff --git a/app/src/components/memory/memoryPlan.test.ts b/app/src/components/memory/memoryPlan.test.tsnew file mode 100644index 0000000000..5f6829b5d8--- /dev/null+++ b/app/src/components/memory/memoryPlan.test.ts@@ -0,0 +1,18 @@+import { describe, expect, it } from 'vitest';++import { MEMORY_QUOTA, planIncludesMemory } from './memoryPlan';++describe('planIncludesMemory', () => {+ it('is true for the plans with a memory quota and false otherwise', () => {+ expect(planIncludesMemory('BASIC')).toBe(true);+ expect(planIncludesMemory('PRO')).toBe(true);+ expect(planIncludesMemory('FREE')).toBe(false);+ expect(planIncludesMemory('')).toBe(false);+ // An inherited key is not a plan.+ expect(planIncludesMemory('toString')).toBe(false);+ });++ it('agrees with the quota table it is derived from', () => {+ for (const plan of Object.keys(MEMORY_QUOTA)) expect(planIncludesMemory(plan)).toBe(true);+ });+});diff --git a/app/src/components/memory/memoryPlan.ts b/app/src/components/memory/memoryPlan.tsnew file mode 100644index 0000000000..575fda8e4f--- /dev/null+++ b/app/src/components/memory/memoryPlan.ts@@ -0,0 +1,18 @@+/**+ * What the account's plan says about hosted (TinyHumans) memory: the storage+ * each plan includes, whether a plan includes memory at all, and where the app+ * sends an "upgrade" or "top up".+ */++/** Free hosted memory per plan; memory inference itself is never charged. */+// ponytail: hard-coded until the backend exposes a memory entitlement; the core's+// PLAN_REQUIRED refusal (#8081) is the backstop when this drifts.+export const MEMORY_QUOTA = { BASIC: '1 GB', PRO: '20 GB' } as const;++/** Whether `plan` (FREE / BASIC / PRO) includes hosted memory. */+export function planIncludesMemory(plan: string): boolean {+ return Object.keys(MEMORY_QUOTA).includes(plan);+}++/** Where the app sends every "top up" / "upgrade" action (`open_billing` in useAppNotices). */+export const BILLING_ROUTE = '/settings/account';diff --git a/app/src/lib/i18n/ar.ts b/app/src/lib/i18n/ar.tsindex aeef07282d..26c1417388 100644--- a/app/src/lib/i18n/ar.ts+++ b/app/src/lib/i18n/ar.ts@@ -592,6 +592,8 @@ const messages: TranslationMap = {'memory.error.planRequired': 'الذاكرة غير مضمّنة في خطتك. قم بترقية خطتك لاستخدامها.','memory.planRequired.title': 'غير مضمّنة في خطتك','memory.planRequired.action': 'ترقية',+ 'memoryPage.engine.builtin.planRequired':+ 'خطتك لا تتضمن الذاكرة المستضافة لدى TinyHumans. قم بالترقية إلى Basic أو Pro لاستخدامها.','alerts.title': 'التنبيهات','alerts.empty': 'لا توجد تنبيهات بعد','alerts.markAllRead': 'تحديد الكل كمقروء',diff --git a/app/src/lib/i18n/bn.ts b/app/src/lib/i18n/bn.tsindex 4aa8e249f7..02909cff16 100644--- a/app/src/lib/i18n/bn.ts+++ b/app/src/lib/i18n/bn.ts@@ -601,6 +601,8 @@ const messages: TranslationMap = {'আপনার প্ল্যানে মেমোরি অন্তর্ভুক্ত নেই। এটি ব্যবহার করতে আপনার প্ল্যান আপগ্রেড করুন।','memory.planRequired.title': 'আপনার প্ল্যানে নেই','memory.planRequired.action': 'আপগ্রেড করুন',+ 'memoryPage.engine.builtin.planRequired':+ 'আপনার প্ল্যানে TinyHumans-হোস্ট করা মেমোরি অন্তর্ভুক্ত নেই। এটি ব্যবহার করতে Basic বা Pro-তে আপগ্রেড করুন।','alerts.title': 'সতর্কতা','alerts.empty': 'এখনো কোনো সতর্কতা নেই','alerts.markAllRead': 'সব পঠিত চিহ্নিত করুন',diff --git a/app/src/lib/i18n/de.ts b/app/src/lib/i18n/de.tsindex fb3912a174..40de3e663c 100644--- a/app/src/lib/i18n/de.ts+++ b/app/src/lib/i18n/de.ts@@ -624,6 +624,8 @@ const messages: TranslationMap = {'Memory ist in deinem Tarif nicht enthalten. Wechsle zu einem höheren Tarif, um es zu nutzen.','memory.planRequired.title': 'Nicht in deinem Tarif','memory.planRequired.action': 'Upgrade',+ 'memoryPage.engine.builtin.planRequired':+ 'Dein Tarif enthält kein von TinyHumans gehostetes Memory. Wechsle zu Basic oder Pro, um es zu nutzen.','alerts.title': 'Warnungen','alerts.empty': 'Noch keine Benachrichtigungen','alerts.markAllRead': 'Alle als gelesen markieren',diff --git a/app/src/lib/i18n/en.ts b/app/src/lib/i18n/en.tsindex f7f7e7328f..079fe41af5 100644--- a/app/src/lib/i18n/en.ts+++ b/app/src/lib/i18n/en.ts@@ -598,6 +598,8 @@ const en: TranslationMap = {'memory.error.planRequired': "Memory isn't included in your plan. Upgrade your plan to use it.",'memory.planRequired.title': 'Not in your plan','memory.planRequired.action': 'Upgrade',+ 'memoryPage.engine.builtin.planRequired':+ "Your plan doesn't include memory hosted by TinyHumans. Upgrade to Basic or Pro to use it.",// Activity surface: Phase 3 renamed tabs'activity.tabs.automations': 'Automations',diff --git a/app/src/lib/i18n/es.ts b/app/src/lib/i18n/es.tsindex 76bbd3f40a..528e72fe49 100644--- a/app/src/lib/i18n/es.ts+++ b/app/src/lib/i18n/es.ts@@ -620,6 +620,8 @@ const messages: TranslationMap = {'La memoria no está incluida en tu plan. Mejora tu plan para usarla.','memory.planRequired.title': 'No incluida en tu plan','memory.planRequired.action': 'Mejorar plan',+ 'memoryPage.engine.builtin.planRequired':+ 'Tu plan no incluye la memoria alojada por TinyHumans. Mejora a Basic o Pro para usarla.','alerts.title': 'Alertas','alerts.empty': 'Sin alertas aún','alerts.markAllRead': 'Marcar todo como leído',diff --git a/app/src/lib/i18n/fr.ts b/app/src/lib/i18n/fr.tsindex b8ae452355..5c4289b164 100644--- a/app/src/lib/i18n/fr.ts+++ b/app/src/lib/i18n/fr.ts@@ -624,6 +624,8 @@ const messages: TranslationMap = {"La mémoire n'est pas incluse dans votre forfait. Passez à un forfait supérieur pour l'utiliser.",'memory.planRequired.title': 'Non incluse dans votre forfait','memory.planRequired.action': 'Mettre à niveau',+ 'memoryPage.engine.builtin.planRequired':+ "Votre forfait n'inclut pas la mémoire hébergée par TinyHumans. Passez à Basic ou Pro pour l'utiliser.",'alerts.title': 'Alertes','alerts.empty': "Aucune alerte pour l'instant",'alerts.markAllRead': 'Tout marquer comme lu',diff --git a/app/src/lib/i18n/hi.ts b/app/src/lib/i18n/hi.tsindex c763332051..d972fbcb76 100644--- a/app/src/lib/i18n/hi.ts+++ b/app/src/lib/i18n/hi.ts@@ -606,6 +606,8 @@ const messages: TranslationMap = {'मेमोरी आपके प्लान में शामिल नहीं है। इसका उपयोग करने के लिए अपना प्लान अपग्रेड करें।','memory.planRequired.title': 'आपके प्लान में नहीं','memory.planRequired.action': 'अपग्रेड करें',+ 'memoryPage.engine.builtin.planRequired':+ 'आपके प्लान में TinyHumans द्वारा होस्ट की गई मेमोरी शामिल नहीं है। इसका उपयोग करने के लिए Basic या Pro में अपग्रेड करें।','alerts.title': 'अलर्ट','alerts.empty': 'अभी कोई अलर्ट नहीं','alerts.markAllRead': 'सभी पढ़ा हुआ मार्क करें',diff --git a/app/src/lib/i18n/id.ts b/app/src/lib/i18n/id.tsindex 6f13407e8b..81bcdafa50 100644--- a/app/src/lib/i18n/id.ts+++ b/app/src/lib/i18n/id.ts@@ -613,6 +613,8 @@ const messages: TranslationMap = {'Memori tidak termasuk dalam paket Anda. Tingkatkan paket Anda untuk menggunakannya.','memory.planRequired.title': 'Tidak termasuk dalam paket Anda','memory.planRequired.action': 'Tingkatkan',+ 'memoryPage.engine.builtin.planRequired':+ 'Paket Anda tidak termasuk memori yang di-hosting oleh TinyHumans. Tingkatkan ke Basic atau Pro untuk menggunakannya.','alerts.title': 'Peringatan','alerts.empty': 'Belum ada peringatan','alerts.markAllRead': 'Tandai semua sudah dibaca',diff --git a/app/src/lib/i18n/it.ts b/app/src/lib/i18n/it.tsindex 7517519bcc..5d043d65ba 100644--- a/app/src/lib/i18n/it.ts+++ b/app/src/lib/i18n/it.ts@@ -620,6 +620,8 @@ const messages: TranslationMap = {'La memoria non è inclusa nel tuo piano. Passa a un piano superiore per usarla.','memory.planRequired.title': 'Non inclusa nel tuo piano','memory.planRequired.action': 'Aggiorna piano',+ 'memoryPage.engine.builtin.planRequired':+ 'Il tuo piano non include la memoria ospitata da TinyHumans. Passa a Basic o Pro per usarla.','alerts.title': 'Avvisi','alerts.empty': 'Nessun avviso','alerts.markAllRead': 'Segna tutti come letti',diff --git a/app/src/lib/i18n/ja.ts b/app/src/lib/i18n/ja.tsindex d4362edadd..d5b75b939b 100644--- a/app/src/lib/i18n/ja.ts+++ b/app/src/lib/i18n/ja.ts@@ -4775,6 +4775,8 @@ const messages: TranslationMap = {'メモリーはご利用のプランに含まれていません。利用するにはプランをアップグレードしてください。','memory.planRequired.title': 'プランに含まれていません','memory.planRequired.action': 'アップグレード',+ 'memoryPage.engine.builtin.planRequired':+ 'ご利用のプランには TinyHumans がホストするメモリーが含まれていません。利用するには Basic または Pro にアップグレードしてください。','onboarding.custom.search.skipForNow': '今はスキップ','onboarding.custom.search.ready': 'Web検索の準備ができました。','onboarding.custom.search.notReady':diff --git a/app/src/lib/i18n/ko.ts b/app/src/lib/i18n/ko.tsindex 2100459a64..df110126a2 100644--- a/app/src/lib/i18n/ko.ts+++ b/app/src/lib/i18n/ko.ts@@ -597,6 +597,8 @@ const messages: TranslationMap = {'메모리는 현재 요금제에 포함되어 있지 않습니다. 사용하려면 요금제를 업그레이드하세요.','memory.planRequired.title': '요금제에 포함되지 않음','memory.planRequired.action': '업그레이드',+ 'memoryPage.engine.builtin.planRequired':+ '현재 요금제에는 TinyHumans가 호스팅하는 메모리가 포함되어 있지 않습니다. 사용하려면 Basic 또는 Pro로 업그레이드하세요.','alerts.title': '알림','alerts.empty': '아직 알림이 없습니다','alerts.markAllRead': '모두 읽음으로 표시',diff --git a/app/src/lib/i18n/pl.ts b/app/src/lib/i18n/pl.tsindex b9f05ee818..6843d8ed5a 100644--- a/app/src/lib/i18n/pl.ts+++ b/app/src/lib/i18n/pl.ts@@ -614,6 +614,8 @@ const messages: TranslationMap = {'Pamięć nie jest uwzględniona w Twoim planie. Ulepsz plan, aby z niej korzystać.','memory.planRequired.title': 'Poza Twoim planem','memory.planRequired.action': 'Ulepsz plan',+ 'memoryPage.engine.builtin.planRequired':+ 'Twój plan nie obejmuje pamięci hostowanej przez TinyHumans. Przejdź na Basic lub Pro, aby z niej korzystać.','alerts.title': 'Alerty','alerts.empty': 'Brak alertów','alerts.markAllRead': 'Oznacz wszystkie jako przeczytane',diff --git a/app/src/lib/i18n/pt.ts b/app/src/lib/i18n/pt.tsindex 429ca776ff..95e21f38ff 100644--- a/app/src/lib/i18n/pt.ts+++ b/app/src/lib/i18n/pt.ts@@ -614,6 +614,8 @@ const messages: TranslationMap = {'A memória não está incluída no seu plano. Faça upgrade do seu plano para usá-la.','memory.planRequired.title': 'Não incluída no seu plano','memory.planRequired.action': 'Fazer upgrade',+ 'memoryPage.engine.builtin.planRequired':+ 'Seu plano não inclui a memória hospedada pela TinyHumans. Faça upgrade para Basic ou Pro para usá-la.','alerts.title': 'Alertas','alerts.empty': 'Nenhum alerta ainda','alerts.markAllRead': 'Marcar tudo como lido',diff --git a/app/src/lib/i18n/ru.ts b/app/src/lib/i18n/ru.tsindex 72363edde4..80bd9aa117 100644--- a/app/src/lib/i18n/ru.ts+++ b/app/src/lib/i18n/ru.ts@@ -610,6 +610,8 @@ const messages: TranslationMap = {'Память не входит в ваш тариф. Перейдите на более высокий тариф, чтобы пользоваться ею.','memory.planRequired.title': 'Не входит в ваш тариф','memory.planRequired.action': 'Улучшить тариф',+ 'memoryPage.engine.builtin.planRequired':+ 'Ваш тариф не включает память, размещённую в TinyHumans. Перейдите на Basic или Pro, чтобы пользоваться ею.','alerts.title': 'Оповещения','alerts.empty': 'Оповещений пока нет','alerts.markAllRead': 'Отметить всё прочитанным',diff --git a/app/src/lib/i18n/tr.ts b/app/src/lib/i18n/tr.tsindex 7c3f0cec92..8274e5263b 100644--- a/app/src/lib/i18n/tr.ts+++ b/app/src/lib/i18n/tr.ts@@ -4428,6 +4428,8 @@ const messages: TranslationMap = {'memory.error.planRequired': 'Bellek planınıza dahil değil. Kullanmak için planınızı yükseltin.','memory.planRequired.title': 'Planınıza dahil değil','memory.planRequired.action': 'Yükselt',+ 'memoryPage.engine.builtin.planRequired':+ "Planınız TinyHumans tarafından barındırılan belleği içermiyor. Kullanmak için Basic veya Pro'ya yükseltin.",'memoryPage.engine.badgeDegraded': 'Kısıtlı çalışıyor','memoryPage.engine.badgeDown': 'Ulaşılamıyor','memoryPage.engine.connecting': 'Bağlanıyor…',diff --git a/app/src/lib/i18n/zh-CN.ts b/app/src/lib/i18n/zh-CN.tsindex e7296754ab..e9b7ac2f8c 100644--- a/app/src/lib/i18n/zh-CN.ts+++ b/app/src/lib/i18n/zh-CN.ts@@ -566,6 +566,8 @@ const messages: TranslationMap = {'memory.error.planRequired': '你的套餐不包含记忆功能。升级套餐即可使用。','memory.planRequired.title': '不在你的套餐中','memory.planRequired.action': '升级',+ 'memoryPage.engine.builtin.planRequired':+ '你的套餐不包含由 TinyHumans 托管的记忆功能。升级到 Basic 或 Pro 即可使用。','alerts.title': '通知','alerts.empty': '暂无通知','alerts.markAllRead': '全部标记为已读',diff --git a/app/test/e2e/specs/memory-plan-required.spec.ts b/app/test/e2e/specs/memory-plan-required.spec.tsnew file mode 100644index 0000000000..3c184cb287--- /dev/null+++ b/app/test/e2e/specs/memory-plan-required.spec.ts@@ -0,0 +1,90 @@+import { expect } from '@wdio/globals';++import { waitForApp } from '../helpers/app-helpers';+import { callOpenhumanRpc } from '../helpers/core-rpc';+import { clickTestId, waitForTestId } from '../helpers/element-helpers';+import { resetApp } from '../helpers/reset-app';+import { navigateViaHash, waitForHomePage, waitForRequest } from '../helpers/shared-flows';+import {+ clearRequestLog,+ getRequestLog,+ setMockBehavior,+ startMockServer,+ stopMockServer,+} from '../mock-server';++/**+ * #8081 — opening a Memory tab on a plan that does not include memory signed+ * the user out.+ *+ * The hosted backend answers `memory/scopes` with `403` and+ * `errorCode: MEMORY_PLAN_REQUIRED`. TinyMemory words that "the session expired+ * or the API key was rejected (HTTP 403 …)", and both the core+ * (`is_session_expired_message` → `SessionExpired`) and the renderer+ * (`classifyRpcError` → `core-rpc-auth-expired`) read "session expired" as a+ * sign-out. Here the mock backend refuses every `/memory/*` call that way, the+ * user is on the hosted TinyHumans engine, and each tab must keep the session+ * and show the "not in your plan" prompt instead.+ */++const LOG = '[MemoryPlanRequiredE2E]';+const USER_ID = 'e2e-memory-plan-required';++/** The tabs from the report, each with the alert its view renders on a failed load. */+const TABS = [+ { chip: 'explorer', alert: 'memory-explorer-error' },+ { chip: 'learnings', alert: 'memory-learnings-error' },+ { chip: 'conversations', alert: 'memory-conversations-error' },+] as const;++describe('Memory tabs on a plan without memory (#8081)', () => {+ before(async function () {+ this.timeout(180_000);+ await startMockServer();+ await waitForApp();+ await resetApp(USER_ID);+ const set = await callOpenhumanRpc('openhuman.memory_engine_set', { engine: 'tinyhumans' });+ expect(set.ok).toBe(true);+ setMockBehavior('memoryForceStatus', '403');+ setMockBehavior('memoryForceCode', 'MEMORY_PLAN_REQUIRED');+ console.log(`${LOG} signed in on the tinyhumans engine; /memory/* answers 403 plan-required`);+ await navigateViaHash('/connections?tab=brain&brain=engine');+ await waitForTestId('memory-page', 30_000);+ });++ after(async () => {+ setMockBehavior('memoryForceStatus', '');+ setMockBehavior('memoryForceCode', '');+ await stopMockServer();+ });++ for (const { chip, alert } of TABS) {+ it(`${chip}: shows the plan prompt and keeps the user signed in`, async function () {+ this.timeout(60_000);+ clearRequestLog();+ await clickTestId(`brain-tab-${chip}`);++ // The refusal really came from the hosted backend, so a pass below is+ // not a tab that never asked.+ const refused = await waitForRequest(getRequestLog, 'GET', '/memory/', 20_000);+ expect(refused).toBeDefined();++ const prompt = await waitForTestId(alert, 20_000);+ expect(await prompt.getAttribute('data-kind')).toBe('plan-required');+ expect(await prompt.getText()).toContain("Memory isn't included in your plan");+ await waitForTestId('memory-upgrade', 5_000);++ // Still on the Memory page, not bounced to sign-in.+ await waitForTestId('memory-page', 5_000);+ const hash = await browser.execute(() => window.location.hash);+ expect(hash).toContain('tab=brain');+ });+ }++ it('the session survives the refusals: Home still loads', async function () {+ this.timeout(30_000);+ await navigateViaHash('/home');+ const marker = await waitForHomePage(20_000);+ expect(marker).toBeTruthy();+ });+});diff --git a/scripts/mock-api/routes/__tests__/memory.test.mjs b/scripts/mock-api/routes/__tests__/memory.test.mjsindex 4f45903ed0..9f813ec059 100644--- a/scripts/mock-api/routes/__tests__/memory.test.mjs+++ b/scripts/mock-api/routes/__tests__/memory.test.mjs@@ -112,6 +112,16 @@ test("memoryForceStatus=402 fails every call with USER_INSUFFICIENT_CREDITS", asassert.equal(r.json.errorCode, "USER_INSUFFICIENT_CREDITS");});+test("memoryForceCode overrides the forced status's errorCode", async () => {+ setMockBehavior("memoryForceStatus", "403");+ setMockBehavior("memoryForceCode", "MEMORY_PLAN_REQUIRED");+ const r = await call("GET", "/memory/scopes");+ assert.equal(r.status, 403);+ assert.equal(r.json.success, false);+ assert.equal(r.json.errorCode, "MEMORY_PLAN_REQUIRED");+ assert.match(r.json.error, /not included in this account's plan/);+});+test("forget refuses an empty selector without confirm_all", async () => {const r = await call("POST", "/memory/forget", { scope: "s", selector: {} });assert.equal(r.status, 422);diff --git a/scripts/mock-api/routes/memory.mjs b/scripts/mock-api/routes/memory.mjsindex dd84c2506f..b0072cdfe8 100644--- a/scripts/mock-api/routes/memory.mjs+++ b/scripts/mock-api/routes/memory.mjs@@ -13,6 +13,9 @@ import { behavior } from "../state.mjs";* Behaviour switches (via `setMockBehavior`):* memoryForceStatus "402" | "401" | "429" | ... every /memory/* call fails* with that status and its canonical errorCode.+ * memoryForceCode with memoryForceStatus, the errorCode to answer instead,+ * e.g. "403" + "MEMORY_PLAN_REQUIRED": memory is not in+ * the account's plan (#8081).** Like the real memory API:* - a reused `Idempotency-Key` header is a 409 `CONFLICT`, never forwarded;@@ -100,6 +103,19 @@ function fail(res, status, code, error) {});}+/** Fails `res` as `memoryForceStatus` asks; false when it asks nothing. */+function failForced(res) {+ const forced = Number(behavior().memoryForceStatus || 0);+ if (forced < 400) return false;+ const code = behavior().memoryForceCode || STATUS_CODES[forced] || "UPSTREAM_ERROR";+ const error =+ code === "MEMORY_PLAN_REQUIRED"+ ? "memory is not included in this account's plan; nothing was processed"+ : "forced by mock";+ fail(res, forced, code, error);+ return true;+}+function ok(res, data, status = 200) {json(res, status, { success: true, data });}@@ -151,11 +167,7 @@ function eraseAll({ req, res }) {fail(res, 401, "UNAUTHORIZED", "missing bearer");return true;}- const forced = Number(behavior().memoryForceStatus || 0);- if (forced >= 400) {- fail(res, forced, STATUS_CODES[forced] || "UPSTREAM_ERROR", "forced by mock");- return true;- }+ if (failForced(res)) return true;const store = storeFor(token);const scopes = new Set(store.events.map((e) => e.scope)).size;store.events = [];@@ -200,11 +212,7 @@ export async function handleMemory(ctx) {fail(res, 401, "UNAUTHORIZED", "missing bearer");return true;}- const forced = Number(behavior().memoryForceStatus || 0);- if (forced >= 400) {- fail(res, forced, STATUS_CODES[forced] || "UPSTREAM_ERROR", "forced by mock");- return true;- }+ if (failForced(res)) return true;const store = storeFor(token);const body = parsedBody && typeof parsedBody === "object" ? parsedBody : {};