Hide context rings without live snapshots

This commit is contained in:
kris
2026-04-06 14:58:30 +08:00
parent 5782804df3
commit 6d90123092
4 changed files with 30 additions and 20 deletions

View File

@@ -297,7 +297,11 @@ public final class WechatSurfaceMapper {
}
private static boolean hasContextIndicator(JSONObject source) {
return true;
if (source.optBoolean("mustFinishBeforeCompaction", false)) {
return true;
}
JSONObject indicator = source.optJSONObject("contextBudgetIndicator");
return indicator != null && indicator.optBoolean("visible", false);
}
private static JSONObject resolveDeviceCapability(JSONObject device, String capabilityKey) {
@@ -441,12 +445,11 @@ public final class WechatSurfaceMapper {
JSONObject avatar = latest.optJSONObject("avatar");
safePut(folder, "avatar", avatar == null ? new JSONObject() : copyJson(avatar));
JSONObject indicator = topContext == null
? buildContextIndicator(100, "safe")
? buildHiddenContextIndicator()
: copyJson(topContext.optJSONObject("contextBudgetIndicator"));
if (indicator == null) {
indicator = buildContextIndicator(100, "safe");
indicator = buildHiddenContextIndicator();
}
safePut(indicator, "visible", true);
safePut(indicator, "style", "ring_percent");
safePut(folder, "contextBudgetIndicator", indicator);
putIfNotEmpty(folder, "contextBudgetSourceNodeId", topContext == null ? "" : topContext.optString("contextBudgetSourceNodeId", ""));
@@ -587,6 +590,13 @@ public final class WechatSurfaceMapper {
return indicator;
}
private static JSONObject buildHiddenContextIndicator() {
JSONObject indicator = new JSONObject();
safePut(indicator, "visible", false);
safePut(indicator, "style", "ring_percent");
return indicator;
}
private static void putIfNotEmpty(JSONObject target, String key, String value) {
if (target == null || value == null || value.trim().isEmpty()) {
return;

View File

@@ -65,11 +65,11 @@ public class WechatSurfaceMapperConversationStatusTest {
assertEquals("上下文稳定", row.contextStatusLabel);
assertEquals("safe", row.contextStatusLevel);
assertEquals(0, row.contextUsagePercent);
assertEquals(true, row.contextIndicatorVisible);
assertEquals(false, row.contextIndicatorVisible);
}
@Test
public void toConversationRow_usesSafeContextDefaultsWhenIndicatorMissing() {
public void toConversationRow_hidesContextIndicatorWhenIndicatorMissing() {
JSONObject item = new StubJSONObject()
.withString("threadTitle", "北区试产线回归")
.withInt("activityIconCount", 0);
@@ -79,7 +79,7 @@ public class WechatSurfaceMapperConversationStatusTest {
assertEquals("上下文稳定", row.contextStatusLabel);
assertEquals("safe", row.contextStatusLevel);
assertEquals(0, row.contextUsagePercent);
assertEquals(true, row.contextIndicatorVisible);
assertEquals(false, row.contextIndicatorVisible);
}
private static final class StubJSONObject extends JSONObject {