…space
Migrate chat message state from component-local useState to a Zustand
store so messages survive session switches and back-navigation.
Three bugs fixed:
- Infinite re-render loop (React nextlevelbuilder#185): inline `?? []` fallback in
Zustand selector created a new array reference every render; Zustand's
Object.is check always detected a change. Fixed with a stable
EMPTY_MESSAGES module constant.
- First message disappearing in new chat: addLocalMessage guarded on the
component-level sessionKey which is still "" when send fires (navigate
is async). Optimistic user message was silently dropped. Fixed by
threading the explicit sessionKey through onMessageAdded in useChatSend.
- restrict_to_workspace always forced to true: HTTP agent update handler
unconditionally overwrote the field; WS handler had no support for it
at all. Fixed both and updated effectiveRestrict() to read the
per-agent setting instead of hardcoding true.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary
use-chat-messages-store) for chat message state so messages persist when switching sessions and navigating back?? []fallback in Zustand selector created a new array reference on every render;Object.isalways detected a "change". Fixed with a stableEMPTY_MESSAGESmodule constantaddLocalMessagechecked the component-levelsessionKeywhich is still""when send fires (navigation is async). Optimistic user message was silently dropped. Fixed by threading the explicitsessionKeythroughonMessageAddedinuseChatSendrestrict_to_workspacealways forced totrue— HTTP agent update handler unconditionally overwrote the field on every update; WS handler had no support for it at all. Fixed both and updatedeffectiveRestrict()to read the per-agent setting instead of hardcodingtrueTest plan
restrict_to_workspacevia HTTP API — value is saved correctly (not always overwritten totrue)restrict_to_workspacevia WSagents.update— field is accepted and persisted🤖 Generated with Claude Code