feat: show codex app server drift on android

This commit is contained in:
AI Bot
2026-06-04 14:56:44 +08:00
parent 0eaf78c3c2
commit 3080f57dbc
6 changed files with 138 additions and 4 deletions

View File

@@ -76,6 +76,33 @@ public class DeviceDetailActivityTest {
assertTrue(viewTreeContainsText(content, "未连接"));
}
@Test
public void renderDeviceShowsCodexAppServerProtocolAndCollaborationSummary() throws Exception {
TestDeviceDetailActivity activity = Robolectric
.buildActivity(
TestDeviceDetailActivity.class,
new Intent()
.putExtra(DeviceDetailActivity.EXTRA_DEVICE_ID, "device-1")
.putExtra(DeviceDetailActivity.EXTRA_DEVICE_NAME, "Mac Studio")
)
.setup()
.get();
ReflectionHelpers.callInstanceMethod(
activity,
"renderDevice",
ReflectionHelpers.ClassParameter.from(JSONObject.class, buildCodexAppServerPayload())
);
View content = activity.findViewById(R.id.screen_content);
assertTrue(viewTreeContainsText(content, "Codex App Server"));
assertTrue(viewTreeContainsText(content, "已连接"));
assertTrue(viewTreeContainsText(content, "线程协作"));
assertTrue(viewTreeContainsText(content, "Boss Broker 可用 · 协作事件可处理 · 2 种模式 · 非原生私聊"));
assertTrue(viewTreeContainsText(content, "协议漂移"));
assertTrue(viewTreeContainsText(content, "兼容 · 失败探针 0 个 · 文档跟进 3 项 · Boss Broker 兜底"));
}
@Test
public void renderDeviceShowsProjectScopedConflictCardAndActions() throws Exception {
TestDeviceDetailActivity activity = Robolectric
@@ -333,6 +360,31 @@ public class DeviceDetailActivityTest {
return payload;
}
private static JSONObject buildCodexAppServerPayload() throws Exception {
JSONObject payload = buildDevicePayload();
JSONObject capabilities = payload
.getJSONObject("workspace")
.getJSONObject("selectedDevice")
.getJSONObject("capabilities");
capabilities.put(
"codexAppServer",
new JSONObject()
.put("connected", true)
.put("lastSeenAt", "2026-06-04T10:00:00+08:00")
.put("metadata", new JSONObject()
.put("threadCollaborationSummary", new JSONObject()
.put("bossBrokerAvailable", true)
.put("collabToolCallHandlerAvailable", true)
.put("directThreadChatSupported", false)
.put("collaborationModeCount", 2))
.put("protocolDriftSummary", new JSONObject()
.put("driftLevel", "compatible")
.put("failedProbeCount", 0)
.put("docFollowupCount", 3)
.put("fallbackStrategy", "Boss Broker + App Server 注入/执行"))));
return payload;
}
public static class TestDeviceDetailActivity extends DeviceDetailActivity {
boolean reloadEnabled = true;
int reloadCount;