Scope folder realtime refreshes by device

This commit is contained in:
kris
2026-04-10 12:55:43 +08:00
parent d1e5a1ac5e
commit 0cba837ed3
11 changed files with 357 additions and 9 deletions

View File

@@ -39,6 +39,48 @@ test("shouldRefreshRealtimeEvent filters scoped conversation updates by project
);
});
test("shouldRefreshRealtimeEvent ignores scoped events that do not identify a project", () => {
assert.equal(
shouldRefreshRealtimeEvent({
eventType: "conversation.updated",
eventData: JSON.stringify({ deviceId: "mac-studio" }),
projectId: "project-a",
}),
false,
);
assert.equal(
shouldRefreshRealtimeEvent({
eventType: "project.context_risk.updated",
eventData: JSON.stringify({ deviceId: "mac-studio" }),
projectIds: ["project-a", "project-b"],
}),
false,
);
});
test("shouldRefreshRealtimeEvent can match scoped device events when page opts into device scope", () => {
assert.equal(
shouldRefreshRealtimeEvent({
eventType: "conversation.updated",
eventData: JSON.stringify({ deviceId: "mac-studio" }),
projectIds: ["project-a", "project-b"],
deviceId: "mac-studio",
}),
true,
);
assert.equal(
shouldRefreshRealtimeEvent({
eventType: "conversation.updated",
eventData: JSON.stringify({ deviceId: "windows-box" }),
projectIds: ["project-a", "project-b"],
deviceId: "mac-studio",
}),
false,
);
});
test("planThrottledRefresh coalesces bursts into one delayed refresh", () => {
const state = createRefreshThrottleState();