Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: retain unknown read state during browser cache replay (#11150)

Adam Eivyc16e1e966d68
diff --git a/server/services/messagePlaywrightSync.js b/server/services/messagePlaywrightSync.js
index 8280ab2c1a..07999d19d0 100644
--- a/server/services/messagePlaywrightSync.js
+++ b/server/services/messagePlaywrightSync.js
@@ -184,7 +184,9 @@ export async function syncPlaywright(account, cache, io, options = {}) {
: !m.providerRowId && m.externalId === extId);
if (cached.length && (msg.providerRowId || (cached.length === 1
&& extracted.filter(row => browserSummaryId(row.date || '', row.from || '', row.subject || '') === extId).length === 1))) {
- const batch = cached.map(m => ({ ...m, isRead: !msg.isUnread, isUnread: msg.isUnread,
+ const batch = cached.map(m => ({ ...m,
+ isRead: msg.isUnread === null ? null : !(msg.isUnread ?? false),
+ isUnread: msg.isUnread === null ? null : (msg.isUnread ?? false),
isPinned: msg.isPinned, isFlagged: msg.isFlagged, isReplied: msg.isReplied }));
messages.push(...batch);
emitMessages(batch);
diff --git a/server/services/messagePlaywrightSync.test.js b/server/services/messagePlaywrightSync.test.js
index 95fd3c1886..7f6216c561 100644
--- a/server/services/messagePlaywrightSync.test.js
+++ b/server/services/messagePlaywrightSync.test.js
@@ -457,3 +457,16 @@ describe('sendPlaywright', () => {
expect(submits).toBe(3);
});
});
+
+
+it('preserves unknown Teams read state when replaying a cached full body', async () => {
+ const { browserSummaryId } = await import('../lib/messageBrowserIdentity.js');
+ findOrOpenPage.mockResolvedValue({ url: 'https://teams.microsoft.com/' });
+ isAuthPage.mockReturnValue(false);
+ tryReadFile.mockResolvedValue('{}');
+ const row = { from: 'Example Sender', subject: '', date: '2026-01-01T12:00:00Z', isUnread: null };
+ evaluateOnPage.mockResolvedValue([row]);
+ const cached = { id: 'cached', externalId: browserSummaryId(row.date, row.from, row.subject), bodyFull: true, bodyText: 'Cached body' };
+ const result = await syncPlaywright({ id: 'example-account', type: 'teams' }, { messages: [cached] });
+ expect(result.messages).toEqual([expect.objectContaining({ id: cached.id, bodyText: 'Cached body', isRead: null, isUnread: null })]);
+});