From afb5f33ec213921526fc532ed78f958904b4a306 Mon Sep 17 00:00:00 2001 From: simoleo89 Date: Sun, 10 May 2026 21:48:49 +0200 Subject: [PATCH] fix(api): IRoomSession.password + sendBackgroundMessage + optional chatColour MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The IRoomSession interface was missing three things that have always existed on the RoomSession implementation: - `password: string` — the room session's join password (used by the reconnect flow in RoomSessionManager). - `sendBackgroundMessage(backgroundImage, backgroundStand, backgroundOverlay, backgroundCard?)` — sends the profile-background composer (used by the React client's BackgroundsView). Plus a signature relaxation: - `sendChatMessage` / `sendShoutMessage` `chatColour` is now optional. The implementation already accepted `undefined` (the composer forwards it through), and every historical call site in the React client passes only 2 args — making the 3rd optional simply types reality. Net renderer typecheck: 26 → 23. The change also drops 7 errors on the consumer side (see ../Nitro-V3 typecheck after the workspace link picks this up). CLAUDE.md gotchas updated to reflect the new interface contract. --- CLAUDE.md | 12 ++++++++---- packages/api/src/nitro/session/IRoomSession.ts | 6 ++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 9370c09..ed82000 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -109,10 +109,14 @@ for the React-side bridge code. - **`SessionDataManager.getUserData(id)` does NOT exist.** Some legacy code in the React client used it under a `getUserData ?` truthy guard; the branch was always dead. Only `getUserDataSnapshot()` exists. -- `IRoomSession.sendChatMessage` / `sendShoutMessage` require **3 args** - (text, styleId, chatColour). The React client's chat-input legacy - passes 2 — known pre-existing gap, do not "fix" the client without - also threading chatColour through the chat composer pipeline. +- `IRoomSession.sendChatMessage` / `sendShoutMessage` accept an optional + `chatColour` 3rd arg (was required pre-2.1.1, now optional to match + the historical call sites in the React client). The implementation + forwards `undefined` to the composer just fine; pass a value only when + you need a specific bubble colour. +- `IRoomSession.password` and `IRoomSession.sendBackgroundMessage` are + now part of the public interface (they always existed on the + implementation class — interface caught up). - The renderer is **synchronous**: `EventDispatcher.dispatchEvent` is a synchronous loop over listeners. Don't add `await` inside the `processEvent` loop — it would change ordering guarantees that diff --git a/packages/api/src/nitro/session/IRoomSession.ts b/packages/api/src/nitro/session/IRoomSession.ts index 02a905e..d12ad5a 100644 --- a/packages/api/src/nitro/session/IRoomSession.ts +++ b/packages/api/src/nitro/session/IRoomSession.ts @@ -9,10 +9,11 @@ export interface IRoomSession setRoomOwner(): void; start(): boolean; reset(roomId: number): void; - sendChatMessage(text: string, styleId: number, chatColour: string): void; - sendShoutMessage(text: string, styleId: number, chatColour: string): void; + sendChatMessage(text: string, styleId: number, chatColour?: string): void; + sendShoutMessage(text: string, styleId: number, chatColour?: string): void; sendWhisperMessage(recipientName: string, text: string, styleId: number): void; sendChatTypingMessage(isTyping: boolean): void; + sendBackgroundMessage(backgroundImage: number, backgroundStand: number, backgroundOverlay: number, backgroundCard?: number): void; sendMottoMessage(motto: string): void; sendDanceMessage(danceId: number): void; sendExpressionMessage(expression: number): void; @@ -50,6 +51,7 @@ export interface IRoomSession sendScriptProceed(): void; userDataManager: IUserDataManager; roomId: number; + password: string; state: string; tradeMode: number; isPrivateRoom: boolean;