Messages — Legacy Redirect & Account Pre-selection
Messages — Legacy Redirect & Account Pre-selection
The messages page (/:company/messages) supports pre-selection of a specific account inbox when a user arrives from a legacy AgentOS messaging-centre link. This ensures continuity for users with bookmarked or shared URLs from the original AgentOS portal.
Legacy URL format
The original AgentOS messaging-centre route uses the following structure:
/:company/:accountType/messaging-centre/:personOID
Example:
/acme/LettingsTenant/messaging-centre/abc123
Redirect behaviour
All legacy messaging-centre URLs are permanently redirected (HTTP 307) to the unified messages page. Both personOID and accountType are forwarded as query parameters so context is preserved:
/acme/messages?personOID=abc123&accountType=LettingsTenant
This redirect is configured in next.config.ts.
Account type mapping
Legacy AgentOS account type names are translated to the portal's internal account type identifiers before being used for account matching:
| Legacy AgentOS type | Portal type |
|---|---|
LettingsTenant | tenant |
LettingsLandlord | landlord |
LettingsProspect | tenant |
SalesVendor | vendor |
SalesApplicantBuyer | buyer |
MaintenanceContractor | contractor |
If the account type is not in this map, it is lower-cased and used as a best-effort hint.
Account pre-selection strategy
When the messages page loads with personOID and/or accountType query parameters, the MessagesClient component attempts to pre-select the correct account inbox using the following ordered strategy:
- Exact match — finds an account where
accountId === personOID - Type-filtered match — finds an account where
accountId === personOIDandtype === accountTypeHint - Type-only fallback — selects the first account matching the hinted type
- Default fallback — selects the first account in the list (standard behaviour for direct visits)
This logic runs once, after accounts have finished loading, and does not interfere with subsequent user-driven account switching.
Direct visits
Navigating directly to /:company/messages (without query parameters) is completely unaffected. The first available account is selected by default, as before.
Component props
The MessagesClient component accepts two optional props to support pre-selection:
| Prop | Type | Description |
|---|---|---|
initialPersonOID | string | undefined | AgentOS person OID extracted from the personOID query parameter. |
initialAccountTypeHint | string | undefined | Normalised account type extracted from the accountType query parameter after legacy name translation. |
These props are populated by the MessagesPage server component (page.tsx) and are not intended to be set directly by consumers.
Error handling
- If
personOIDdoes not match any loaded account, the matching strategy falls back gracefully through each level until a default account is selected. - An unknown
accountTypevalue causes the component to skip type-based strategies and fall back to the first available account. - No error is surfaced to the user in any fallback scenario.