fix(assistant): worded health tile instead of raw UNKNOWN #61

Merged
KofTwentyTwo merged 1 commits from fix/assistant-health-tile-wording into develop 2026-10-16 15:20:16 +00:00
2 changed files with 24 additions and 5 deletions

No files matched your search

@@ -42,6 +42,24 @@ public class AssistantHealthWidget extends AbstractWidgetRenderer
{
public static final String NAME = "assistantHealth";
public static final String NOT_CHECKED = "Not checked yet";
/*******************************************************************************
** Human words for a health status; unknown means no check has reported yet.
*******************************************************************************/
static String wording(HealthStatus status)
{
return (switch(status)
{
case UP -> "Healthy";
case DEGRADED -> "Degraded";
case DOWN -> "Down";
case UNKNOWN -> NOT_CHECKED;
});
}
/*******************************************************************************
@@ -72,8 +90,8 @@ public class AssistantHealthWidget extends AbstractWidgetRenderer
.map(check -> runner.getLastOutcome(check.getName()))
.map(outcome -> outcome == null ? HealthStatus.UNKNOWN : outcome.getStatus()).toArray(HealthStatus[]::new));
}
return (new RenderWidgetOutput(new StatisticsData().withCount(status.name())
.withCountContext("System Health")
return (new RenderWidgetOutput(new StatisticsData().withCount(wording(status))
.withCountContext("System Health. Provider checks run every 1 to 5 minutes; model checks every 6 hours")
.withCountURL(FilterLinkBuilder.href("health_check", List.of(Map.of("fieldName", "component", "operator", "EQUALS", "values", List.of("assistant")))))));
}
}
@@ -606,7 +606,8 @@ class AssistantHealthChecksTest extends BaseAssistantTest
assertThat(qInstance.getWidget(AssistantHealthWidget.NAME).getType()).isEqualTo(WidgetType.STATISTICS.getType());
var renderer = new AssistantHealthWidget();
StatisticsData data = (StatisticsData) renderer.render(new RenderWidgetInput()).getWidgetData();
assertThat(data.getCount()).isEqualTo("UNKNOWN");
assertThat(data.getCount()).isEqualTo("Not checked yet");
assertThat(data.getCountContext()).contains("Provider checks run every 1 to 5 minutes");
assertThat(data.getCountURL()).startsWith("/app/").contains("health_check", "assistant");
try(var central = cached("assistant.provider." + row.getId(), HealthCheckOutcome.up("Reachable"), Instant.now()))
{
@@ -614,14 +615,14 @@ class AssistantHealthChecksTest extends BaseAssistantTest
cache.setAccessible(true);
cache.invoke(central, AssistantHealthChecks.CLIENT_ERRORS, HealthCheckOutcome.up("0 client errors reported in the last hour"));
data = (StatisticsData) renderer.render(new RenderWidgetInput()).getWidgetData();
assertThat(data.getCount()).isEqualTo("UP");
assertThat(data.getCount()).isEqualTo("Healthy");
//////////////////////////////////////////////////////////////////
// many client errors in the last hour show on the card as well //
//////////////////////////////////////////////////////////////////
cache.invoke(central, AssistantHealthChecks.CLIENT_ERRORS, HealthCheckOutcome.degraded("25 client errors reported in the last hour"));
data = (StatisticsData) renderer.render(new RenderWidgetInput()).getWidgetData();
assertThat(data.getCount()).isEqualTo("DEGRADED");
assertThat(data.getCount()).isEqualTo("Degraded");
}
}
}