This PR fixes critical issues with remote method registration and message routing in multi-window applications, specifically addressing hangs and cross-talk errors when launching new windows or detaching components.
Key Changes:
Window ID Propagation (Neo.worker.Manager):
- Updated
sendMessage to automatically attach the Main Thread's windowId to outgoing messages if not already present (opts.windowId ??= me.windowId).
- This ensures that
registerRemote calls (and all other messages) originating from a specific window carry the correct identifier.
- Impact: Workers (like App) can now correctly identify the source of a request and route the reply back to the specific Main Thread (Window) that sent it, preventing replies from being sent to the wrong window (e.g., the primary window instead of a popup).
Message Forwarding Fix (Neo.worker.Manager):
- Updated
onWorkerMessage to explicitly set response.destination = data.origin when forwarding message replies.
- Impact: Prevents the Manager from incorrectly attempting to route a reply to 'main' (causing a crash) when it should be forwarding it back to the original sender (e.g., 'app').
Robust Worker Checking (Neo.worker.Base, Neo.worker.Manager):
- Added
hasWorker(name) method to Neo.worker.Base (checking Neo.config) and Neo.worker.Manager (checking getWorker).
- Impact: Allows safe verification of optional workers (like 'canvas', 'task', 'service') before attempting communication, preventing runtime errors when they are disabled.
Goal:
Ensure stable and correct message routing in complex multi-window environments, enabling features like AgentOS component detachment to work without crashing the original window or hanging the new one.
This PR fixes critical issues with remote method registration and message routing in multi-window applications, specifically addressing hangs and cross-talk errors when launching new windows or detaching components.
Key Changes:
Window ID Propagation (
Neo.worker.Manager):sendMessageto automatically attach the Main Thread'swindowIdto outgoing messages if not already present (opts.windowId ??= me.windowId).registerRemotecalls (and all other messages) originating from a specific window carry the correct identifier.Message Forwarding Fix (
Neo.worker.Manager):onWorkerMessageto explicitly setresponse.destination = data.originwhen forwarding message replies.Robust Worker Checking (
Neo.worker.Base,Neo.worker.Manager):hasWorker(name)method toNeo.worker.Base(checkingNeo.config) andNeo.worker.Manager(checkinggetWorker).Goal: Ensure stable and correct message routing in complex multi-window environments, enabling features like
AgentOScomponent detachment to work without crashing the original window or hanging the new one.