XYLEX Group
DevelopmentChat System

Overview

Chat package overview

The @suitsbooks/chat package provides a reusable, realtime, virtualized chat experience that follows SuitsBooks conventions:

  • API access: Uses {APP_CONFIG.api.suitsbooks} for fetch/insert (/fetch/data, /data/insert) with required X-Company-Id, X-Organization-Id, X-User-Id headers via existing hooks
  • Realtime: Subscribes to Supabase Postgres changes on the target table
  • Virtualization: Efficient rendering using @tanstack/react-virtual
  • Mentions: Out-of-the-box @ mentions using react-mentions, sourced from the users table
  • Attachments: S3-compatible uploads (DigitalOcean Spaces) via /api/files/upload/upload-legacy, with previews for images and videos
  • UI conventions: Buttons, icons, and typography comply with workspace rules (brand actions, rounded-sm, text-primary, text-secondary)

Components

  • Chat: High-level chat component (list + input + realtime + mentions + attachments)
  • MessageList: Virtualized message list
  • MessageItem: An individual message with avatar, timestamp, and attachment previews
  • MessageInput: Input with react-mentions and an attach button

Required environment / assumptions

  • The app is configured with APP_CONFIG and the standard API endpoints.
  • Supabase client is configured in lib/supabase/client.
  • User context is available via useUserStore with user_id, company_id, organization_id.