githubnext/chopinPublic

Let's compose rich plans together

Derive effective access during render instead of an Effect

The effectiveCanEdit/effectiveCanManage Effect in RoomWorkspace only
recomputed a pure function of the canEdit/archivedAt/canManage props; it
did not synchronize with any external system, so it caused an extra
render showing stale authorization before the Effect ran. Replace it
with the React 'adjust state during render when a prop changes'
pattern, comparing the previous props in a ref and updating state
synchronously in the render body. The latestCanEdit/latestCanManage
refs (read by later socket handlers) and the state setters keep their
prior update semantics.

Verified with 'bun run types' (all workspaces pass) and 'bun test
apps/web' (304 pass, 0 fail); 'bunx oxlint apps/web/src/room-workspace.tsx'
reports 0 warnings/errors. 'bun run ci' could not run locally because the
dprint plugin download is blocked in this sandbox.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
COGAgithub-actions[bot] and Copilot authored committed by GitHub
4852049Patch
Parent9882eb3
1 file changed+17-2
StackedSplit
apps/web/src/room-workspace.tsx+17 โˆ’2