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
test(memory): pin the language-switch edge of out-of-credits matching
M3gA-Mindb73aa5542692
diff --git a/app/src/components/memory/MemoryErrorAlert.test.tsx b/app/src/components/memory/MemoryErrorAlert.test.tsxindex 4a881decac..02f4816e0a 100644--- a/app/src/components/memory/MemoryErrorAlert.test.tsx+++ b/app/src/components/memory/MemoryErrorAlert.test.tsx@@ -1,9 +1,11 @@-import { fireEvent, screen } from '@testing-library/react';+import { act, fireEvent, screen } from '@testing-library/react';+import { useState } from 'react';import { Route, Routes } from 'react-router-dom';import { describe, expect, it } from 'vitest';-import { useT } from '../../lib/i18n/I18nContext';+import { I18nProvider, useT } from '../../lib/i18n/I18nContext';import { memoryErrorMessage } from '../../services/api/memoryApi';+import { setLocale } from '../../store/localeSlice';import { renderWithProviders } from '../../test/test-utils';import MemoryErrorAlert from './MemoryErrorAlert';@@ -80,4 +82,30 @@ describe('MemoryErrorAlert', () => {expect(screen.queryByRole('button', { name: 'Retry' })).not.toBeInTheDocument();expect(screen.getByTestId('memory-top-up')).toBeInTheDocument();});++ // Accepted edge of matching on the message: views keep the text they made+ // when the action failed, so after a language switch it no longer matches+ // the new language's text and falls back to the error alert.+ it('falls back to the error alert for a message made before a language switch', () => {+ function Frozen() {+ const { t } = useT();+ const [message] = useState(() => memoryErrorMessage(coded('INSUFFICIENT_CREDITS'), t));+ return <MemoryErrorAlert message={message} data-testid="alert" />;+ }+ const { store } = renderWithProviders(+ <I18nProvider>+ <Frozen />+ </I18nProvider>+ );+ expect(screen.getByTestId('alert')).toHaveAttribute('data-kind', 'out-of-credits');++ act(() => {+ store.dispatch(setLocale('fr'));+ });+ const alert = screen.getByTestId('alert');+ expect(alert).toHaveAttribute('data-variant', 'destructive');+ expect(alert).not.toHaveAttribute('data-kind');+ expect(alert).toHaveTextContent('Top up to restore it');+ expect(screen.queryByTestId('memory-top-up')).not.toBeInTheDocument();+ });});diff --git a/app/src/services/api/memoryApi.ts b/app/src/services/api/memoryApi.tsindex 6b2c80e36b..12cf9895ac 100644--- a/app/src/services/api/memoryApi.ts+++ b/app/src/services/api/memoryApi.ts@@ -632,6 +632,10 @@ export function memoryErrorMessage(* produced (with `t`). That translated text is returned for* `INSUFFICIENT_CREDITS` and for nothing else, so the views that keep only the* message can still offer a top-up instead of an error.+ *+ * Known edge: a message produced in one language no longer matches after the+ * user switches language, so that stale message falls back to the error alert+ * (it still explains the top-up). The next failed action re-derives it.*/export function isOutOfCreditsMessage(message: string | null,