Refresh project detail on context risk events

This commit is contained in:
kris
2026-04-07 14:29:54 +08:00
parent f83ab50d6b
commit aaaf1926b4
2 changed files with 28 additions and 0 deletions

View File

@@ -330,6 +330,7 @@ public class ProjectDetailActivity extends BossScreenActivity {
}
return "project.messages.updated".equals(event.eventName)
|| "conversation.updated".equals(event.eventName)
|| "project.context_risk.updated".equals(event.eventName)
|| "master_agent.task.updated".equals(event.eventName);
}

View File

@@ -134,6 +134,33 @@ public class ProjectDetailActivityRealtimeTest {
assertEquals(2, activity.reloadCount);
}
@Test
public void matchingProjectContextRiskEventTriggersReload() throws Exception {
Intent intent = new Intent()
.putExtra(ProjectDetailActivity.EXTRA_PROJECT_ID, "project-1")
.putExtra(ProjectDetailActivity.EXTRA_PROJECT_NAME, "北区试产线");
TestRealtimeProjectDetailActivity activity = Robolectric
.buildActivity(TestRealtimeProjectDetailActivity.class, intent)
.setup()
.resume()
.get();
ReflectionHelpers.callInstanceMethod(
activity,
"handleRealtimeEvent",
ReflectionHelpers.ClassParameter.from(
BossRealtimeEvent.class,
new BossRealtimeEvent(
"project.context_risk.updated",
new JSONObject().put("projectId", "project-1").put("deviceId", "mac-studio")
)
)
);
Shadows.shadowOf(activity.getMainLooper()).idle();
assertEquals(1, activity.reloadCount);
}
@Test
public void duplicateRealtimeEventsWithDifferentAtAreDeduped() throws Exception {
Intent intent = new Intent()