c9fe4879e0
Task 12 (the AuthContext userKeyState refactor) replaced the per-device DeviceRecord lookup with a localStorage UUID via ensureInstallId(). That UUID was then passed straight through to messages.sender_device_id on INSERT. The messages_insert_member RLS policy requires sender_device_id to be NULL OR to match a row in `devices` owned by the caller. The localStorage UUID matches neither -> 403 -> outbox endlessly retries with "Wiederhole". Fix: SendMessageParams.senderDeviceId becomes optional, and the message INSERT coerces undefined to NULL. The column is pure telemetry post-conv- keys so passing NULL is correct. Existing call sites that hand in ensureInstallId() still typecheck (string is assignable to string|null|undefined) but the row is written with NULL until those callers stop passing it.