Context
Agreement chat UI exists (components/agreements/agreement-chat.tsx) but today it talks to Supabase via service-role Server Actions (lib/actions/agreement-chat.ts), bypassing Nest auth.
Nest already has JWT endpoints (ready after BE work):
GET /v1/agreements/:agreementId/messages
POST /v1/agreements/:agreementId/messages
Depends on: ThalosBackend#86 (schema sender_id + fail-hard participants).
Problem
- UI agreement ids are often
AGR-* / mocks / contractId — not the UUID FK expected by agreement_messages → Postgres UUID errors (#92).
- Create flow injects optimistic
AGR-… ids and does not persist a shared DB agreement UUID for both parties.
- Chat does not use Nest JWT → no participant checks on the FE path.
SHOW_MOCKED_AGREEMENTS defaults to true (prod risk).
Scope (keep tight — make A↔B chat work)
Out of scope
- Business wizard full Trustless create (can stay limited if personal A↔B works)
- Approve/release on-chain wiring beyond what’s needed to create a real agreement
- Admin mock page
- Realtime WebSockets (polling OK)
- Trustless API-key proxy (separate security follow-up)
Acceptance criteria
- User A creates a real agreement with User B as counterparty.
- Both see the same agreement UUID in the dashboard (not
AGR-*).
- A opens chat → sends a message → B opens the same agreement chat → sees it → replies → A sees reply.
- Opening chat on a mock id does not hit Postgres / Nest with invalid UUID.
- Production/demo with mocks disabled does not show demo agreements by default.
Test plan
Related
DoD
- PR on
main with Nest chat client + UUID path
- Proof: short clip or screenshots A↔B + mock guard
Closes #NN (this issue) and Closes #92 if fixed here
Context
Agreement chat UI exists (
components/agreements/agreement-chat.tsx) but today it talks to Supabase via service-role Server Actions (lib/actions/agreement-chat.ts), bypassing Nest auth.Nest already has JWT endpoints (ready after BE work):
GET /v1/agreements/:agreementId/messagesPOST /v1/agreements/:agreementId/messagesDepends on: ThalosBackend#86 (schema
sender_id+ fail-hard participants).Problem
AGR-*/ mocks /contractId— not the UUID FK expected byagreement_messages→ Postgres UUID errors (#92).AGR-…ids and does not persist a shared DB agreement UUID for both parties.SHOW_MOCKED_AGREEMENTSdefaults to true (prod risk).Scope (keep tight — make A↔B chat work)
contractId→ agreements UUID before opening chat).AGR-*ids into chat after create; UI chat must receive a real UUID.AgreementChatto Nest vialib/api+ JWT (auth_token/ auth store). Remove or stop using Supabase service-role chat actions for this path.AGR-*,ENT-*), do not call API — show clear “demo / unavailable” (covers fix: block agreement chat (and mutating actions) on mocked non-UUID agreement ids #92).NEXT_PUBLIC_SHOW_MOCKED_AGREEMENTS=falseor invert default); gate businessENT-*the same way as personal.Out of scope
Acceptance criteria
AGR-*).Test plan
NEXT_PUBLIC_API_URLpoints at Nest/v1Related
DoD
mainwith Nest chat client + UUID pathCloses #NN(this issue) andCloses #92if fixed here