Frontend Aligned to New "Tenant" Terminology, Plus Mail, Admin, and Vendor Reliability Fixes
Executive summary
The frontend (Mail and Admin apps) has been updated to match the backend's renaming of "entity/client" to tenant across 318 files, so the UI, navigation, and data contracts now speak the same language as the API. The same change set bundles several targeted bug fixes for mail editing, batch reassignment, admin user management, and vendor upload progress tracking. This is a foundational consistency update reaching the QA environment.
Why this was needed
The backend renamed its core organizational concept from "entity/client" to "tenant" and regenerated its API contract. Until the frontend followed suit, field names and routes drifted from the backend (e.g. forms sending entity_id/tenant_id where the API expected tenant_id/tenant_update_id), which silently dropped data on save. Aligning terminology end-to-end prevents these mismatches and keeps the codebase maintainable as the product scales to a multi-tenant model.
Client / user impact
- Tenant and sub-tenant dropdowns, forms, and detail views across Mail and Admin now read and write the correct backend fields, so edits actually save.
- Batch bulk reassignment of a tenant now works — previously the field was silently dropped and the action was a no-op.
- Admin user create/edit correctly persists the tenant association.
- The Admin IDP Tenant Mappings page loads at its new address and matches the sidebar/breadcrumb labels.
- Vendor "View Files" upload progress now connects reliably and no longer gets stuck in a reconnect loop.
- Minor UI fixes: duplicate dropdown entries in client/tenant selectors and a duplicate column in the mail contents grid are resolved.
Technical scope
- Terminology rename: regenerated API types (143 Mail + 35 Admin model files) and propagated
client/entity → tenantthrough services, TanStack queries/mutations, types, and ~25 components; renamed routes (/v1/clients → /v1/tenants) and page directories (entities → tenants,idp-entity-mappings → idp-tenant-mappings). - Payload disambiguation: aligned update fields to the backend schema —
update_tenant_id(mail overview/mutations),tenant_update_id(batch bulk update),tenant_id(admin user types, Zod schema, dialog), and corrected the upload-center PUT contract. - Vendor WebSocket fix (
useVendorUploadSocket.ts): moved callback props into a ref to stop reconnect churn on every render, corrected the subscribe message type tosubscribe_task, and skip reconnect on close codes 1000/1001/1008. - Comments WebSocket: migrated to cookie-based auth (token param was hardcoded
undefined, blocking connection); added a temporary/api/auth/ws-tokencompatibility route. - Behavior fix: batch selection in MailForm no longer pre-fills "Assigned To".
- Adjusted ESLint ignores for generated API type paths in the monorepo.
Risk & mitigation
Risk is moderate due to breadth (318 files) rather than depth — most changes are mechanical renames plus regenerated types. The main risk is a missed reference causing a stale field name to reach the backend (the class of bug this PR itself fixes in three places). Mitigation: the rename is type-driven (TypeScript surfaces mismatches at build time), the change is staged in QA before production, and several review rounds already caught and corrected silent-drop payload bugs.
QA validation focus
- Add Mail form: tenant/sub-tenant dropdowns populate; saving persists the selected tenant.
- Mail overview edit: changing tenant saves correctly.
- Batch create and batch bulk reassignment: confirm tenant change actually applies (not a no-op).
- Admin Tenants page CRUD; Admin user create/edit persists tenant.
- Admin IDP Tenant Mappings loads at
/idp-tenant-mappingswith matching title/breadcrumb. - Page-statistics tenant-level drill-down works.
- Vendor "View Files": upload progress streams live with no reconnect loop; verify behavior on an expired/invalid session.
- Spot-check client/tenant selector dropdowns for duplicate entries and the mail contents grid for duplicate columns.