selectedCompany on the auth session, updated via POST /auth/web/switch-company in webAuthEndpoints.ts).switchCompanyAction and triggers a full page reload (NavUser.tsx).res.locals.company._id (calendar, schedule, quotes, inspections, events). Cross-company behavior exists only in narrow admin paths (e.g. cc-dashboard with getAllowedCompanyIds, GET /company/my-companies, Client Care Dashboard).membershipSchema.ts) with different roles and permissions per _companyId; copyMembershipToCompanies.ts provisions separate employee records per company but does not unify the tools experience.Implement in dependency order via blockedBy:
homeCompanyId + includedCompanyIds[] ⊆ user’s active memberships._companyId membership (not a naive union of all permissions)._companyId (explicit picker or row context); no ambiguous cross-company writes.companyIds must always be intersected with allowed memberships (pattern from ccDashboard.ts).Coordinates session, authorization, federated APIs, and tools UI. Detail lives on child issues. Key touchpoints:
attik-backend/src/util/functions/betterAuth/web/webAuthEndpoints.ts, attik-frontend/src/actions/switchCompany.tsattik-backend/src/models/membershipSchema.ts, attik-frontend/src/components/navbar/NavUser.tsxattik-backend/src/routes/ccDashboard.ts, attik-backend/src/routes/company.ts (/my-companies), attik-frontend/src/app/admin/client-care-dashboard/attik-frontend/src/app/tools/calendar/MasterCalendar.tsx, attik-backend/src/routes/calendar.ts, attik-backend/src/routes/schedule.tsOut of scope: Merging tenant data; replacing instance-management; implementing ATT-1714 or ATT-1763 (integrate when those ship).
flowchart TB
subgraph today [Today]
S[Session selectedCompany]
T[Tools UI single company]
API[APIs filter res.locals.company]
S --> T --> API
end
subgraph target [Unified workspace]
W[Workspace home + included companies]
F[Federated read APIs]
UI[One shell with company chips on rows]
W --> F --> UI
end
today -.-> target
Please authenticate to join the conversation.
Planned
Main App
4 days ago
Linear
Get notified by email when there are changes.
Planned
Main App
4 days ago
Linear
Get notified by email when there are changes.