From 77f3150af4dde91be5634780f5c925d609157e9e Mon Sep 17 00:00:00 2001 From: Pierre De Lancre Date: Wed, 2 Sep 2026 02:22:38 +0300 Subject: [PATCH] =?UTF-8?q?matrix:=20widen=20sync=20event=20window=20backw?= =?UTF-8?q?ards=20=E2=80=94=20sender=20precedes=20type=20marker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/matrix.zig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/matrix.zig b/src/matrix.zig index d0a954f..becf4a1 100644 --- a/src/matrix.zig +++ b/src/matrix.zig @@ -121,8 +121,11 @@ pub fn sync(alloc: std.mem.Allocator, io: Io, token: []const u8, since: []const var i: usize = 0; while (std.mem.indexOfPos(u8, resp, i, "\"m.room.message\"")) |pos| { defer i = pos + 15; + // Event layout: sender (and event_id) come BEFORE the type marker, + // body comes after it in content — window spans both sides. + const win_start = pos -| 600; const win_end = @min(resp.len, pos + 1500); - const win = resp[pos..win_end]; + const win = resp[win_start..win_end]; const sender = letta.jsonStr(alloc, win, 0, "sender") orelse continue; const body = letta.jsonStr(alloc, win, 0, "body") orelse { alloc.free(sender.val);