From ccd77be74a307abc7e3c8251e30acdd964e93fb7 Mon Sep 17 00:00:00 2001 From: Robin Date: Wed, 14 May 2025 10:05:19 -0400 Subject: [PATCH] Fix state events being hidden from widgets in read_events actions (#29954) This widget driver method was mistakenly filtering all state events out of the responses to read_events fromWidget actions. This was a hold-over from back when read_events had two different behaviors depending on whether you specified a state_key (i.e. before the introduction of the update_state action). --- src/stores/widgets/StopGapWidgetDriver.ts | 4 ++-- test/unit-tests/stores/widgets/StopGapWidgetDriver-test.ts | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/stores/widgets/StopGapWidgetDriver.ts b/src/stores/widgets/StopGapWidgetDriver.ts index e0bc85746f..d4c0f8930c 100644 --- a/src/stores/widgets/StopGapWidgetDriver.ts +++ b/src/stores/widgets/StopGapWidgetDriver.ts @@ -498,9 +498,9 @@ export class StopGapWidgetDriver extends WidgetDriver { if (results.length >= limit) break; if (since !== undefined && ev.getId() === since) break; - if (ev.getType() !== eventType || ev.isState()) continue; + if (ev.getType() !== eventType) continue; if (eventType === EventType.RoomMessage && msgtype && msgtype !== ev.getContent()["msgtype"]) continue; - if (ev.getStateKey() !== undefined && stateKey !== undefined && ev.getStateKey() !== stateKey) continue; + if (stateKey !== undefined && ev.getStateKey() !== stateKey) continue; results.push(ev); } diff --git a/test/unit-tests/stores/widgets/StopGapWidgetDriver-test.ts b/test/unit-tests/stores/widgets/StopGapWidgetDriver-test.ts index 04f0ec1404..e08a83dd02 100644 --- a/test/unit-tests/stores/widgets/StopGapWidgetDriver-test.ts +++ b/test/unit-tests/stores/widgets/StopGapWidgetDriver-test.ts @@ -708,6 +708,7 @@ describe("StopGapWidgetDriver", () => { id: "$event-id2", type: "org.example.foo", user: "@alice:example.org", + skey: "", content: { hello: "world" }, room: "!1:example.org", }); @@ -726,6 +727,12 @@ describe("StopGapWidgetDriver", () => { ).toEqual([event2, event1].map((e) => e.getEffectiveEvent())); }); + it("reads state events", async () => { + expect( + await driver.readRoomTimeline("!1:example.org", "org.example.foo", undefined, "", 10, undefined), + ).toEqual([event2.getEffectiveEvent()]); + }); + it("reads up to a limit", async () => { expect( await driver.readRoomTimeline("!1:example.org", "org.example.foo", undefined, undefined, 1, undefined),