From 7329c7526ee20055bf5806c38b2194ce079e44ee Mon Sep 17 00:00:00 2001 From: TastelessVoid Date: Tue, 24 Feb 2026 17:30:55 +0100 Subject: [PATCH] Finished implementing widgets --- src/app/features/widgets/WidgetIframe.tsx | 9 ++- src/app/features/widgets/WidgetsDrawer.tsx | 4 +- src/app/hooks/useCommands.ts | 54 +++++++++++++++ src/app/hooks/useRoomWidgets.ts | 76 ++++++++++++++++++++-- 4 files changed, 134 insertions(+), 9 deletions(-) diff --git a/src/app/features/widgets/WidgetIframe.tsx b/src/app/features/widgets/WidgetIframe.tsx index 960c34a2..e184fcaf 100644 --- a/src/app/features/widgets/WidgetIframe.tsx +++ b/src/app/features/widgets/WidgetIframe.tsx @@ -38,7 +38,8 @@ export function WidgetIframe({ widget, roomId, mx, onCapabilityRequest }: Widget userId, displayName, avatarUrl, - widget.id + widget.id, + mx ); useEffect(() => { @@ -60,6 +61,11 @@ export function WidgetIframe({ widget, roomId, mx, onCapabilityRequest }: Widget messaging.once('ready', () => setReady(true)); + // Set iframe src after ClientWidgetApi is listening for the load event. + // This avoids a race condition where the iframe loads before the widget + // API transport is ready to perform the capability handshake. + iframe.src = resolvedUrl; + messaging.on('action:org.matrix.msc2876.read_events', (ev: CustomEvent) => { const room = mx.getRoom(roomId); const events: Partial[] = []; @@ -135,7 +141,6 @@ export function WidgetIframe({ widget, roomId, mx, onCapabilityRequest }: Widget