fix(lotus): reply immediately to lotus actions with no mounted handler; new fromWidget actions
Lotus toWidget actions with no handler used to sit in the LazyEventEmitter
backlog forever (host timed out; stale replay on remount). They now get
an immediate {} reply. Adds RequestState and DenoiseState to the enum
(fromWidget) with a test pinning the toWidget/fromWidget split.
Fixes #18
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
This commit is contained in:
co-authored by
Claude Opus 5
parent
bb639bb92d
commit
501e3fb5ac
+18
-2
@@ -115,14 +115,30 @@ export const initializeWidget = (
|
||||
ElementWidgetActions.JoinCall,
|
||||
ElementWidgetActions.HangupCall,
|
||||
ElementWidgetActions.DeviceMute,
|
||||
// [lotus] custom toWidget actions handled by the fork (focus, audio-inject)
|
||||
...LOTUS_TO_WIDGET_ACTIONS,
|
||||
].forEach((action) => {
|
||||
api.on(`action:${action}`, (ev: CustomEvent<IWidgetApiRequest>) => {
|
||||
ev.preventDefault();
|
||||
lazyActions.emit(action, ev);
|
||||
});
|
||||
});
|
||||
// [lotus] custom toWidget actions handled by the fork (focus,
|
||||
// audio-inject, decorations, ...). Unlike the upstream actions above
|
||||
// (whose handlers are process-lifetime), lotus handlers are
|
||||
// registered/torn down with their owning React effect, so a request can
|
||||
// arrive while none is mounted. `LazyEventEmitter.emit` would otherwise
|
||||
// backlog it forever (never replied to, replayed stale on the next
|
||||
// registration — see LazyEventEmitter), and the host's
|
||||
// `transport.send` would hang until its own timeout. Reply immediately
|
||||
// with `{}` when there's no handler instead, so a torn-down lotus
|
||||
// action behaves like a no-op rather than a silent stall.
|
||||
LOTUS_TO_WIDGET_ACTIONS.forEach((action) => {
|
||||
api.on(`action:${action}`, (ev: CustomEvent<IWidgetApiRequest>) => {
|
||||
ev.preventDefault();
|
||||
if (!lazyActions.emit(action, ev)) {
|
||||
api.transport.reply(ev.detail, {});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Now, initialize the matryoshka MatrixClient (so named because it routes
|
||||
// all requests through the host client via the widget API)
|
||||
|
||||
Reference in New Issue
Block a user