# Changelog

All notable changes to Realtime Ai are documented in this file.

There was no formal version number or changelog before this release; the prior
working state of the app is referred to as the **2.1 baseline** (see
`backups/version-2.1-before-v2.5-upgrade/BACKUP_README.md`).

## [2.5.0] — 2026-07-21

### Added
- **Complete public website.** Replaced the root login redirect with a modern,
  responsive marketing site and shared navigation/footer. Dedicated Home,
  About, How It Works, Pricing, Contact, Privacy and Terms routes now connect
  visitors to the separate user and administrator sign-in experiences. Pricing
  uses live package configuration and the contact page uses the existing
  server-backed email endpoint.
- **Dark public brand experience.** Applied a charcoal/teal public theme,
  replaced temporary letter marks across public, user, admin, mobile and login
  navigation with the supplied Realtime Ai emblem, and added an original
  generated Input/Output portrait pair to the Home studio demonstration.
- **Realtime face-swap workspace.** The user AI Studio now includes the missing
  side-by-side Input and Output experience: camera or MP4/WebM input, protected
  reference-face upload, transformation instructions, realtime Lucy 2.5 output,
  connection state, fullscreen preview, credit status, and responsive mobile
  stacking. Studio media is attached to the user's active session.
- **Secure provider client tokens.** The server now mints short-lived Decart
  credentials restricted to the configured model, requesting web origin, user
  session, and maximum duration. Permanent provider credentials never enter the
  frontend bundle or API response.
- **Complete standard-user dashboard.** Replaced the temporary `/account`
  welcome card with a responsive dashboard shell and dedicated Overview, AI
  Studio, My Sessions, Session Detail, Assessments, Wallet & Billing,
  Notifications, Help & Support, and Account Settings routes. The user shell
  includes desktop navigation, a mobile off-canvas drawer, sticky header,
  theme control, profile menu, secure logout, loading/empty/error states, and
  mobile-friendly cards and tables.
- **User-owned APIs and privacy boundaries.** Added dashboard summaries,
  paginated session history/detail, owner-checked signed media previews,
  account-scoped notifications, and durable support requests. Support requests
  are available to permitted administrators for investigation and resolution.
- **Granular admin roles (RBAC).** New optional `admin_role` field on user
  accounts: `super_admin`, `support_agent`, `finance_staff`, `technical_staff`.
  Each role is restricted to a permission matrix (`server/permissions.js`)
  enforced on every sensitive admin route. Existing admin accounts
  automatically default to `super_admin` — no behavior change for current
  admins. See `ADMIN_USER_GUIDE.md` for what each role can do.
- **Audit logging.** Every sensitive admin action (user edits, credit/minute
  adjustments, password resets, package changes, payment approvals/rejections,
  settings changes, session terminations, session-issue refunds) is now
  recorded with admin identity, IP, target, and a details payload. Viewable at
  **Admin → Audit Logs**, filterable by action.
- **In-app notifications.** New notification feed for admins covering session
  failures/terminations and refunds, with unread counts, mark-as-read, and
  mark-all-as-read. Surfaced via the header bell icon and a dedicated
  **Notifications** page.
- **Session Issues.** A new admin view derived from sessions that ended
  abnormally (expired mid-generation due to running out of credits, or
  force-terminated by an admin). Includes severity/category classification and
  a one-click credit refund action tied into the transaction ledger and audit
  log.
- **Session detail & termination.** `GET /api/admin/sessions/:id` for a single
  session's full technical/billing detail, and the ability for admins with the
  `sessions.manage` permission to terminate an active session directly from
  the dashboard.
- **Studio Workflow view.** Visualizes the real session pipeline (active →
  completed / expired / terminated) and generation-model usage breakdown.
- **Reports & Analytics.** Revenue-by-day and sessions-by-day charts, plus
  headline stats (revenue, users, credits consumed), derived from existing
  session/transaction data — no new data collection required.
- **Versioned data migrations.** `server/migrations.js` introduces a
  `schema_version` field and an idempotent migration runner, applied
  automatically on startup. This release ships migration `1`, which adds the
  `audit_logs` and `notifications` collections and backfills `admin_role`.
- **Brand-new admin dashboard frontend** (`client/src/`), which did not
  previously exist as source in this repository (see "Fixed" below). Built
  with React + react-router-dom, a CSS-custom-properties design system
  (light/dark theme), a responsive shell (desktop sidebar with collapse,
  mobile off-canvas drawer, sticky header with global search/notifications/
  profile menu, breadcrumbs), and full pages for Overview, Studio Sessions,
  Studio Session Detail, Studio Workflow, Users, Session Issues, Session Issue
  Detail, Transactions, Reports, Notifications, Settings, and Audit Logs.
- **Separate authentication entry points.** Standard users sign in at `/login`
  and administrators at `/admin`; role-aware guards send each account to its
  correct protected area without redirect loops.
- **Assessments.** Added versioned assessment storage, user submission,
  server-paginated admin list/detail pages, reviewer decisions and history,
  a `session_reviewer` role, and audit logging.
- **Secure Media Library.** Added permission-scoped metadata listing,
  five-minute HMAC-signed previews, storage-path containment, private no-store
  responses, access audit logs, and archival controls.
- **Complete studio operations.** Studio Sessions now provides server-side
  search, status/user/type/date/duration filters, secure source/target
  thumbnails, minute allocation and usage, processing progress, quality,
  error state, timestamps, pagination, and dedicated detail actions.
- **Durable workflow and issue operations.** Session events and issues are now
  persisted through migration 3. The workflow page shows all eight processing
  stages, bottlenecks, provider health, live activity, and guarded retry,
  pause, and cancel controls. Issue details include billing impact, protected
  evidence, technical context, assignment, contact, escalation, resolution,
  refund, and manual-credit actions with confirmation and audit records.
- **Expanded users and assessments.** User lists now include access status,
  last login, usage totals, verification and plan data; detail pages include
  all nine requested history/security tabs. Assessment lists and detail pages
  now expose session linkage, moderation, quality/safety checks, reviewer
  decisions, protected media, and audit history.
- **User Detail and Support.** Added responsive user history tabs and a focused
  support queue for unresolved user-impacting session cases.
- **Automated tests.** Added migration idempotency and RBAC matrix coverage.
- **Route-level code splitting.** Dashboard modules load on demand while the
  global shell remains visible with an accessible loading state.

### Changed
- `server/db.js`: `getOverview()` now also returns `completed_sessions`,
  `sessions_with_issues`, `total_sessions`, and `total_credits_used`.
- `server/index.js`: existing admin routes (`users`, `packages`, `payments`,
  `settings`, `sessions/:id/terminate`, etc.) are now gated by
  `requirePermission(...)` in addition to the existing `adminMiddleware`, and
  emit audit log entries after successful mutations. No existing route
  signatures, request/response shapes, or business logic were changed — only
  permission checks and audit logging were layered on top.
- Settings page now exposes a **System Info** tab showing current/previous
  version and upgrade status.

### Fixed
- Fixed Plesk/shared-host startup failures caused by an unnecessary MySQL
  `CREATE DATABASE` permission check, and emitted the release `package.json`
  without a UTF-8 BOM for hosting-panel script parsers.
- User Studio billing now starts only after the Decart realtime connection is
  confirmed; token creation, media preparation, and failed connection attempts
  remain unbilled. Provider balance/quota failures are hidden from standard
  users and replaced with instructions to contact an administrator. The Studio
  eyebrow no longer exposes the Lucy model/version name.
- Realtime face swap now sends the reference image and prompt during the
  initial Lucy connection handshake, retries once with a fresh short-lived
  token when the provider WebSocket closes during startup, and does not mark
  disconnected states as live. The empty Output panel now shows only
  `Connecting...` until the generated stream arrives.
- **Rebuilt the missing React frontend from scratch.** `client/index.html` had
  always referenced `/src/main.jsx`, but no `client/src` directory or `.jsx`
  files existed anywhere in the repository (only a compiled `client/dist/`
  bundle was present) — the source was lost prior to this project ever having
  version control. This release restores a working, editable frontend source
  tree wired against the existing backend APIs.
- `client/vite.config.js` had no React JSX runtime configured
  (`@vitejs/plugin-react` was never installed), which would have caused a
  `ReferenceError: React is not defined` crash the moment real JSX components
  were added. Fixed by setting `esbuild: { jsx: 'automatic' }` — no new
  dependency required.

### Security
- Upgraded Nodemailer to 9.0.3 to resolve the published message-level raw
  content file-access/SSRF advisory detected by the production dependency
  audit.
- The AI provider key is no longer returned from the studio connection API;
  clients are directed through the authenticated server proxy.
- All new admin API routes require authentication (`authMiddleware`), admin
  role (`adminMiddleware`), and the specific permission for that action
  (`requirePermission`), following the existing project security model
  (JWT bearer auth, bcrypt password hashing).
- Every credit/minute adjustment, refund, password reset, and settings change
  is now attributable to a specific admin account via the audit log.

### Infrastructure
- Hardened the production release builder with required runtime-module checks,
  sensitive-file exclusions, syntax validation, Version 2.5 package metadata,
  and a SHA-256 archive checksum. Fixed omitted migration and permission modules
  that would otherwise cause the packaged server to fail at startup.
- Initialized a git repository for the project (none existed before) with a
  baseline commit on `master` and all Version 2.5 work on `upgrade/version-2.5`.
- Added a full pre-upgrade source backup at
  `backups/version-2.1-before-v2.5-upgrade/` with a `BACKUP_README.md`
  documenting exactly what was/wasn't included and how to restore it.

### Known limitations
- Reports & Analytics uses lightweight CSS/inline-SVG bar charts rather than a
  charting library, to avoid adding a new frontend dependency.
