FleetOS Bug Fixes - Session Startup Doc

Last Updated: 2026-01-14 Goal: Fix all known bugs before autonomous Ralph-Loop system deployment

Current Status: IN PROGRESS

Working on fixing 18 test failures from True_Test_Matrix_Doc.md to deliver a "best case first" build.


Completed Fixes

1. Demo Mode Detection (CleanLanding.tsx:344)

Problem: Fleet demo user had UUID-style ID that didn't match userId.startsWith('demo-') check in UnifiedDashboard Fix: Changed fleet demo user ID from b7f9b0e3-e581-42df-a797-f237a4ab6276 to demo-fleet-001

2. Demo Seeding Race Condition (App.tsx:1047-1053, 1189-1195)

Problem: Navigation happened before demo data seeding completed, causing empty dashboards Fix: Changed from non-blocking .catch() to awaited try/catch:

// Before: seedSupplierRelationships(companyId).catch(err => {...});
// After: await seedSupplierRelationships(companyId);

3. Mock User Fallback Missing Fields (App.tsx:1086-1098, 1228-1240)

Problem: Mock user fallback was missing roles and activeRole fields required by safeStorage validation Fix: Added required fields to both supplier and fleet mock users:

roles: ['FLEET'],           // Required for safeStorage validation
activeRole: 'FLEET',        // Required for safeStorage validation

4. Test Helper Regex Too Broad (tests/fleetos/helpers.ts:64)

Problem: waitForURL(/view=FLEETOS_FLEET_DASHBOARD|view=FLEETOS/) matched FLEETOS_FLEET_ONBOARDING prematurely Fix: Changed to specific pattern: waitForURL(/view=FLEETOS_FLEET_DASHBOARD/)


In Progress: Session Persistence (F1.1.7)

The Problem

After signup, user refreshes page and sees signup form instead of dashboard.

Root Cause Analysis

  1. After signup, handleNavigation('FLEETOS_FLEET_DASHBOARD') only sets React state, not URL

  2. URL stays as /?view=FLEETOS_FLEET_ONBOARDING

  3. On refresh, getInitialView() reads URL param first, returns to onboarding

  4. User data IS in localStorage but view restoration logic wasn't checking it properly

Fix Applied (App.tsx:364-428)

Rewrote getInitialView() to:

  1. Check if user is logged in from localStorage FIRST

  2. If URL param is an onboarding view but user is logged in, redirect to dashboard

  3. Only use URL param for non-onboarding views

Key Code Location

Test Still Failing

Run: npx playwright test tests/fleetos/01-authentication.spec.ts -g "F1.1.7" --reporter=list

The test might now pass after the helpers.ts fix. Need to verify.


Remaining Failing Tests

Test ID
Description
Likely Issue

F1.1.3

Submit with valid email shows success message

Locator finds multiple elements matching /phone|verification/i - test needs .first()

F1.1.8

Expired/invalid link shows error state

Auth verify page may not show error text for invalid tokens

F1.2.1

Click Get Started opens signup form

Need to investigate

S6.2.1

Click Get Started opens signup form

Need to investigate


Key Files Reference

File
Purpose

App.tsx

Main app - routing, auth state, signup handlers

lib/safeStorage.ts

localStorage wrapper with validation (requires id, roles, activeRole)

services/AuthService.ts

Magic link auth, session management (uses fleetos_session key)

components/fleetos/pages/UnifiedDashboard.tsx

Dashboard component with demo detection

components/fleetos/pages/CleanLanding.tsx

Landing page with demo buttons

components/fleetos/forms/MinimalSignup.tsx

Signup form component

tests/fleetos/helpers.ts

Playwright test helpers

tests/fleetos/01-authentication.spec.ts

Authentication test suite

docs/True_Test_Matrix_Doc.md

Full test matrix with results


Storage Keys

  • t420_user - Main user state (via safeStorage)

  • fleetos_session - Auth session (via AuthService)

  • currentView - Temporary view persistence for demo buttons


Next Steps

  1. Start dev server: npm run dev

  2. Run session persistence test to verify fix: npx playwright test tests/fleetos/01-authentication.spec.ts -g "F1.1.7"

  3. If passing, run full auth test suite: npx playwright test tests/fleetos/01-authentication.spec.ts

  4. Fix remaining failures

  5. Update True_Test_Matrix_Doc.md with results

  6. Commit all fixes


Commands

Last updated

Was this helpful?