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(app): pin route redirect contracts and the embedding-state warning\n\nTwo new vitest specs, no existing file touched.\n\nAppRoutes.redirects.test.tsx — every `<Navigate>` in the route table asserted\nby resolved location rather than by what rendered, plus a drift guard that\nfails when a redirect is added to AppRoutes.tsx and not to the table here.\n\n The existing `/accounts` guard in AppRoutes.auth.test.tsx cannot fail:\n it asserts the `Accounts` component rendered, and `Accounts` is also the\n element for `/chat/:threadId?`, so deleting the redirect outright leaves it\n green. Verified by doing exactly that — old spec 2 passed, new spec 3 failed.\n\n `replace` was unasserted anywhere. A pushed redirect leaves the retired path\n on the history stack, so Back returns to it and is redirected forward again.\n Nine cases now pin REPLACE.\n\nMemorySourceRow.pipelineWarning.test.tsx — the "stored without vectors" banner\nmust reach the screen. The verdict behind it (deriveSourcePipelineHealth) is\nalready exhaustively covered; the *rendering* was not, so neutering the JSX\nblock left the whole suite green. That is the shape of the incident where\n2,581 chunks sat with 0 embedded and no indicator appeared anywhere.\n\nEvery assertion was proven by reverting the behaviour it covers and confirming\nthe failure names it:\n - drop `?tab=messaging` from /channels -> 2 fail\n - drop `replace` from /feedback -> 1 fail (PUSH vs REPLACE)\n - retarget /routines to /chat -> 1 fail\n - add an untracked redirect -> drift guard fails\n - neuter `{ingestedOnly && ...}` -> 6 fail\n - force `settled = false` (wedged progress) -> 6 fail\n - force `settled = true` (no suppression) -> 1 fail\n
M3gA-Mind628c47b9d281
diff --git a/app/src/AppRoutes.redirects.test.tsx b/app/src/AppRoutes.redirects.test.tsxnew file mode 100644index 0000000000..126037405b--- /dev/null+++ b/app/src/AppRoutes.redirects.test.tsx@@ -0,0 +1,141 @@+/**+ * Back-compat redirect contracts for the desktop route table.+ *+ * Every `<Navigate>` in `AppRoutes.tsx` is a promise to somebody's bookmark: a+ * route that used to be top-level and now lives somewhere else. Breaking one is+ * silent — the app still renders *a* page, just not the one the link meant.+ *+ * This asserts a different contract from `test/playwright/specs/navigation.spec.ts`,+ * which covers four of these at the browser layer. That spec asserts the hash+ * *begins with* the landing path, which cannot tell `/connections` apart from+ * `/connections?tab=messaging`, and says nothing about `replace`. Here the whole+ * resolved location is compared exactly, and the `replace` semantics — the thing+ * that stops the Back button bouncing a user into a redirect loop — are asserted+ * on their own.+ *+ * Mocks mirror `AppRoutes.auth.test.tsx`: every leaf page is stubbed so this+ * exercises the router and nothing else.+ */+import { render, screen } from '@testing-library/react';+import type React from 'react';+import { MemoryRouter, useLocation, useNavigationType } from 'react-router-dom';+import { describe, expect, it, vi } from 'vitest';++vi.mock('./lib/platform', () => ({ getIsMobile: () => false }));++vi.mock('./components/PublicRoute', () => ({+ default: ({ children }: { children: React.ReactNode }) => <>{children}</>,+}));+vi.mock('./components/ProtectedRoute', () => ({+ default: ({ children }: { children: React.ReactNode }) => <>{children}</>,+}));+vi.mock('./components/DefaultRedirect', () => ({+ default: () => <div data-testid="default-redirect" />,+}));++vi.mock('./pages/WebCallbackPage', () => ({ default: () => <div /> }));+vi.mock('./AppRoutesIOS', () => ({ default: () => <div /> }));+vi.mock('./features/human/HumanPage', () => ({ default: () => <div /> }));+vi.mock('./pages/Accounts', () => ({ default: () => <div /> }));+vi.mock('./pages/Brain', () => ({ default: () => <div /> }));+vi.mock('./pages/dev/AgentInsightsPreview', () => ({ default: () => <div /> }));+vi.mock('./pages/dev/UiGallery', () => ({ default: () => <div /> }));+vi.mock('./pages/Invites', () => ({ default: () => <div /> }));+vi.mock('./pages/Notifications', () => ({ default: () => <div /> }));+vi.mock('./pages/onboarding/Onboarding', () => ({ default: () => <div /> }));+vi.mock('./pages/PttOverlayPage', () => ({ PttOverlayPage: () => <div /> }));+vi.mock('./pages/Rewards', () => ({ default: () => <div /> }));+vi.mock('./pages/Settings', () => ({ default: () => <div /> }));+vi.mock('./pages/Skills', () => ({ default: () => <div /> }));+vi.mock('./pages/Welcome', () => ({ default: () => <div /> }));+vi.mock('./pages/WorkflowsRun', () => ({ default: () => <div /> }));++const AppRoutes = (await import('./AppRoutes')).default;++/** Reports the router's resolved location, so a redirect is observed rather than inferred. */+function LocationProbe() {+ const location = useLocation();+ return (+ <>+ <div data-testid="pathname">{location.pathname}</div>+ <div data-testid="search">{location.search}</div>+ </>+ );+}++/** Reports the router's last navigation action, so `replace` is observed rather than assumed. */+function ActionProbe() {+ return <div data-testid="nav-type">{useNavigationType()}</div>;+}++function landingFor(entry: string) {+ render(+ <MemoryRouter initialEntries={[entry]}>+ <AppRoutes />+ <LocationProbe />+ </MemoryRouter>+ );+ return {+ pathname: screen.getByTestId('pathname').textContent,+ search: screen.getByTestId('search').textContent,+ };+}++// Every `<Navigate>` in AppRoutes.tsx, read off the route table. If a redirect+// is added there and not here, `every redirect in the route table is covered`+// below fails — the list cannot silently fall behind the code.+const REDIRECTS: Array<{ from: string; pathname: string; search: string }> = [+ { from: '/home', pathname: '/chat', search: '' },+ { from: '/activity', pathname: '/settings/notifications', search: '' },+ { from: '/intelligence', pathname: '/settings/notifications', search: '' },+ { from: '/skills', pathname: '/connections', search: '' },+ { from: '/accounts', pathname: '/chat', search: '' },+ { from: '/channels', pathname: '/connections', search: '?tab=messaging' },+ { from: '/feedback', pathname: '/settings/feedback', search: '' },+ { from: '/routines', pathname: '/flows', search: '' },+ { from: '/webhooks', pathname: '/settings/integrations', search: '' },+];++describe('AppRoutes back-compat redirects', () => {+ for (const { from, pathname, search } of REDIRECTS) {+ it(`sends ${from} to ${pathname}${search}`, () => {+ expect(landingFor(from)).toEqual({ pathname, search });+ });+ }++ it('carries the messaging tab through the /channels redirect', () => {+ // Singled out because it is the only redirect whose contract is a query+ // string. A prefix match on the path alone passes even when `?tab=messaging`+ // is dropped, which lands the user on the wrong Connections tab.+ expect(landingFor('/channels').search).toBe('?tab=messaging');+ });++ it('every redirect in the route table is covered by this spec', async () => {+ const [fs, path] = await Promise.all([import('node:fs'), import('node:path')]);+ // vitest runs with `app/` as cwd (test/vitest.config.ts sets the root).+ const source = fs.readFileSync(path.resolve('src/AppRoutes.tsx'), 'utf8');+ const routed = [...source.matchAll(/<Route path="([^"]+)" element={<Navigate /g)].map(+ match => match[1]+ );+ expect(routed.sort()).toEqual(REDIRECTS.map(r => r.from).sort());+ });+});++describe('AppRoutes redirects replace rather than push', () => {+ // A redirect that pushes leaves the retired path on the history stack, so+ // Back returns to it and is immediately redirected forward again — the user+ // cannot leave. `replace` is what prevents that. Nothing else asserts it, and+ // dropping `replace` from a `<Navigate>` is a one-word edit that every other+ // test in the tree still passes.+ for (const { from } of REDIRECTS) {+ it(`${from} navigates by REPLACE, not PUSH`, () => {+ render(+ <MemoryRouter initialEntries={[from]}>+ <AppRoutes />+ <ActionProbe />+ </MemoryRouter>+ );+ expect(screen.getByTestId('nav-type')).toHaveTextContent('REPLACE');+ });+ }+});diff --git a/app/src/components/intelligence/MemorySourceRow.pipelineWarning.test.tsx b/app/src/components/intelligence/MemorySourceRow.pipelineWarning.test.tsxnew file mode 100644index 0000000000..2bf440c1de--- /dev/null+++ b/app/src/components/intelligence/MemorySourceRow.pipelineWarning.test.tsx@@ -0,0 +1,180 @@+/**+ * The "stored without vectors" warning must actually reach the screen.+ *+ * Motivating incident: a workspace sat with 2,581 chunks synced and 0 embedded,+ * and no degraded indicator appeared anywhere in the UI. The user's semantic+ * search was silently returning nothing findable, while every surface reported+ * a healthy sync.+ *+ * The *verdict* behind that warning — `deriveSourcePipelineHealth` — is already+ * exhaustively covered by `sourcePipelineStatus.test.ts` (14 cases, every+ * branch). What was NOT covered is whether the verdict is ever rendered:+ * `MemorySourceRow.test.tsx` only exercises the settings disclosure. Deleting+ * the whole `{ingestedOnly && …}` block from `MemorySourceRow.tsx` leaves every+ * other test in the repo green — a correct verdict computed into a void, which+ * is exactly the shape of the reported incident.+ *+ * These tests therefore assert the *rendered* contract, not the derivation:+ * the warning appears when chunks are stored without vectors, it carries the+ * message the user needs, and — the easy thing to get wrong — it is suppressed+ * only while a sync is genuinely in flight.+ */+import { render, screen } from '@testing-library/react';+import { describe, expect, it, vi } from 'vitest';++import type { MemorySourceEntry, SourceStatus } from '../../services/memorySourcesService';+import { MemorySourceRow } from './MemorySourceRow';++vi.mock('../../lib/i18n/I18nContext', () => ({ useT: () => ({ t: (k: string) => k }) }));++const SOURCE_ID = 'src_brain_1';++function makeSource(overrides: Partial<MemorySourceEntry> = {}): MemorySourceEntry {+ return {+ id: SOURCE_ID,+ kind: 'github_repo',+ label: 'My Repo',+ enabled: true,+ url: 'https://github.com/org/repo',+ ...overrides,+ };+}++/** The incident's shape: everything ingested, nothing embedded. */+function storedWithoutVectors(overrides: Partial<SourceStatus> = {}): SourceStatus {+ return {+ source_id: SOURCE_ID,+ chunks_synced: 2581,+ chunks_pending: 2581,+ last_chunk_at_ms: Date.now(),+ freshness: 'recent',+ ...overrides,+ } as SourceStatus;+}++function renderRow(overrides: Partial<React.ComponentProps<typeof MemorySourceRow>> = {}) {+ const props: React.ComponentProps<typeof MemorySourceRow> = {+ source: makeSource(),+ status: null,+ pipeline: null,+ isAuthenticated: true,+ isSyncing: false,+ isBuilding: false,+ progress: null,+ result: null,+ settingsExpanded: false,+ onToggle: vi.fn(),+ onRemove: vi.fn(),+ onSync: vi.fn(),+ onBuild: vi.fn(),+ onToggleSettings: vi.fn(),+ onSettingsSaved: vi.fn(),+ onViewHealth: vi.fn(),+ onSignIn: vi.fn(),+ ...overrides,+ };+ render(+ <ul>+ <MemorySourceRow {...props} />+ </ul>+ );+}++const warning = () => screen.queryByTestId(`memory-source-pipeline-warning-${SOURCE_ID}`);++describe('MemorySourceRow — the row tells the truth about embedding state', () => {+ it('shows the pipeline warning when every synced chunk is unembedded', () => {+ renderRow({ status: storedWithoutVectors() });++ const banner = warning();+ expect(banner).toBeInTheDocument();+ expect(banner).toHaveTextContent('sync.pipeline.storedWithoutVectors');+ });++ it('shows the warning for a single unembedded chunk, not just a large backlog', () => {+ // There is no threshold in the contract: one chunk that semantic search+ // cannot reach is still a source that is not retrieval-ready.+ renderRow({ status: storedWithoutVectors({ chunks_synced: 10, chunks_pending: 1 }) });++ expect(warning()).toBeInTheDocument();+ });++ it('stays silent when every chunk is embedded', () => {+ renderRow({ status: storedWithoutVectors({ chunks_pending: 0 }) });++ expect(warning()).not.toBeInTheDocument();+ });++ it('stays silent before anything has been ingested', () => {+ // A brand-new source has no chunks and therefore nothing to warn about;+ // warning here would train users to ignore the banner.+ renderRow({ status: storedWithoutVectors({ chunks_synced: 0, chunks_pending: 0 }) });++ expect(warning()).not.toBeInTheDocument();+ });++ it('surfaces the warning from the global semantic-recall latch with no pending chunks', () => {+ // The per-source count can be 0 while the process-wide embeddings provider+ // is down; the row still is not retrieval-ready.+ renderRow({+ status: storedWithoutVectors({ chunks_pending: 0 }),+ pipeline: {+ status: 'degraded',+ degraded: { semantic_recall: true },+ } as unknown as React.ComponentProps<typeof MemorySourceRow>['pipeline'],+ });++ expect(warning()).toBeInTheDocument();+ expect(warning()).toHaveTextContent('sync.pipeline.storedWithoutVectors');+ });+});++describe('MemorySourceRow — the warning is suppressed only while a sync is in flight', () => {+ // `settled = !progress && !result` in MemorySourceRow.tsx. This suppression is+ // correct (mid-sync `chunks_pending` is legitimately transient) and is also the+ // most plausible way for the indicator to never appear: a source wedged in a+ // progress state would warn about nothing forever. Both directions are pinned.+ it('hides the warning while a sync is actively reporting progress', () => {+ renderRow({+ status: storedWithoutVectors(),+ progress: { processed: 10, total: 2581 } as unknown as React.ComponentProps<+ typeof MemorySourceRow+ >['progress'],+ });++ expect(warning()).not.toBeInTheDocument();+ });++ it('reports the truth again once the sync has settled', () => {+ renderRow({ status: storedWithoutVectors(), progress: null, result: null });++ expect(warning()).toBeInTheDocument();+ });++ it('offers sign-in only when the failure is a missing backend session', () => {+ renderRow({+ isAuthenticated: false,+ status: storedWithoutVectors(),+ pipeline: {+ status: 'degraded',+ first_blocking_cause: { code: 'auth_missing' },+ } as unknown as React.ComponentProps<typeof MemorySourceRow>['pipeline'],+ });++ expect(screen.getByTestId(`memory-source-signin-${SOURCE_ID}`)).toBeInTheDocument();+ });++ it('does not offer sign-in for a non-auth embeddings failure', () => {+ renderRow({+ isAuthenticated: false,+ status: storedWithoutVectors(),+ pipeline: {+ status: 'degraded',+ first_blocking_cause: { code: 'provider_unreachable' },+ } as unknown as React.ComponentProps<typeof MemorySourceRow>['pipeline'],+ });++ expect(warning()).toBeInTheDocument();+ expect(screen.queryByTestId(`memory-source-signin-${SOURCE_ID}`)).not.toBeInTheDocument();+ });+});