Reference
Dashboard integration (JWT session & operator UI)
The Next.js app in `apps/dashboard` is a developer / operator console and live chat demo. This page summarizes how it authenticates and which Worker feature
The Next.js app in apps/dashboard is a developer / operator console and live chat demo. This page summarizes how it authenticates and which Worker features it exercises.
Session storage (security)
- State is persisted under
fluxychat.dashboard.session.v1insessionStorage(cleared when the browser tab closes). - Fields:
adminJwt,memberJwt,activeProject(id, name, optionalapiKey, plan snapshot). - One-time migration from legacy
localStorageis performed on first load.
Use Onboarding or Projects to mint or paste tokens. The SDK client on the home page prefers memberJwt, then adminJwt, for Authorization on REST and WebSocket.
Operator pages
| Path | Purpose | Typical token |
|---|---|---|
/ | Live useChat demo + ChatWindow | Member or admin JWT |
/onboarding | End-to-end: project, keys, room, message, agent | Starts with admin |
/projects | Projects, API keys, plan | Admin JWT |
/rooms | List/create/rename/delete rooms; members | Admin JWT for mutations |
/agents | CRUD agents, invoke, runs | JWT with appropriate roles |
/admin | Webhooks list, PATCH/DELETE, automation, audit snippets | Admin / owner |
/billing | Plan, Stripe checkout/portal when configured | Admin |
/analytics | Costs, SLO, launch KPIs | Admin |
/search | Message search | JWT |
/privacy | Policy copy + GDPR export download + erasure request | Export: member or admin; erasure: owner/admin JWT |
GDPR API (Worker)
GET /gdpr/export— Right of access / portability. Returns JSON attachment for thesubin the JWT.DELETE /gdpr/delete— Erasure for thesubin the JWT within the project; requiresowneroradminroles. Redacts messages and removes related rows per Worker implementation.
The Privacy page calls these endpoints using the stored session tokens.
SDK transport behavior (useChat)
Relevant to the home demo:
- Send message: REST when the client has a JWT; otherwise WebSocket payload.
- Edit / delete message: REST when authenticated; on failure, WebSocket fallback for the same operation.
- Reconnect: exponential backoff; after repeated failures the hook falls back to SSE (
GET /rooms/:id/streamviaconnectSSE), then REST polling if SSE is unavailable. useChathistory replay (Portal-style):replay: "connect"(default) — REST fetch on mount + apply WShistoryevents.replay: "request"— skip auto-load for heavy rooms; callloadHistory()when the UI needs messages.replayHistoryOnReconnect— passed toconnectRoom(defaulttruewhenreplayis"connect").
connectionStatus:connected|connecting|reconnecting|disconnected|sse|polling.
File uploads & composed attachments
- Worker endpoint
POST /upload(JWT) stores bytes in R2 whenATTACHMENTSis bound; response returns a public/attachments/...URL. - The home
ChatWindowpassesuploadComposerFile→FluxyChatClient.uploadFile(roomId, file)so image / file / audio icons use a native picker instead of URL prompts. POST /messagesaccepts an optionalattachmentsarray (same shape as websocket sends); entries are validated tohttp(s)URLs and persisted to D1 for history.
Notifications (P7)
- Worker:
GET /notifications,POST /notifications/:id/read,POST /notifications/read-all - SDK:
client.listNotifications(),useNotifications(client),useChat(\{ markReadLatest: true \}) - Console:
/notificationsinbox; overview card on/; unread badges on/rooms - Deep link:
/rooms?room=<roomId>selects a room after load
Composer @mentions
The home page wires @fluxy-chat/ui ChatWindow with:
mentionSuggestions— built by loadingclient.listAgents()and passing\{ handle, label, agentId \}per bot (handle falls back to a slug derived from name).typingAgentId— fromuseChat().typingAgentId, which merges websocketagentTypingevents (includesagentId) with an in-flight id whileinvokeAgentruns.
ChatWindow merges those rows with onlineUsers IDs and @handles parsed from recent message text so the dropdown stays useful outside the Agents list alone. Matching is prefix on handle or substring on display label.
Worker automation hooks (optional)
Configure on the Worker (see apps/worker/wrangler.toml comments):
| Env prefix | Behaviour |
|---|---|
AUTO_ROOM_SUMMARY_* | After new messages (REST, WS, bot, agent paths), enqueue an automatic room_summary when AI is configured and thresholds/cooldowns pass. Webhook room.summary fires when summaries are persisted. |
BUILTIN_MODERATION_* | Substring blocklist match → moderation row (auto_flag), automation_events, webhook moderation.auto_flag; surfaced alongside user reports under admin reports filters. |
Environment
NEXT_PUBLIC_FLUXYCHAT_WORKER_URL— Worker base URL (defaulthttp://127.0.0.1:8787in dev).
See also: Auth cookbook, Troubleshooting.