fix: sidebar route selection and missing routes after server restart
Two sidebar bugs fixed: 1. Route entries never highlighted on navigation because sidebar-utils generated /apps/ paths for route children while effectiveSelectedPath normalizes to /exchanges/. The design system does exact string matching. 2. Routes disappeared from sidebar when agents had no recent exchange data. Heartbeat carried routeStates (with route IDs as keys) but AgentRegistryService.heartbeat() never updated AgentInfo.routeIds. After server restart, auto-heal registered agents with empty routes, leaving ClickHouse (24h window) as the only discovery source. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -57,6 +57,11 @@ public record AgentInfo(
|
||||
state, registeredAt, lastHeartbeat, newStaleTransitionTime);
|
||||
}
|
||||
|
||||
public AgentInfo withRouteIds(List<String> newRouteIds) {
|
||||
return new AgentInfo(instanceId, displayName, applicationId, environmentId, version, newRouteIds, capabilities,
|
||||
state, registeredAt, lastHeartbeat, staleTransitionTime);
|
||||
}
|
||||
|
||||
public AgentInfo withCapabilities(Map<String, Object> newCapabilities) {
|
||||
return new AgentInfo(instanceId, displayName, applicationId, environmentId, version, routeIds, newCapabilities,
|
||||
state, registeredAt, lastHeartbeat, staleTransitionTime);
|
||||
|
||||
@@ -71,14 +71,18 @@ public class AgentRegistryService {
|
||||
|
||||
/**
|
||||
* Process a heartbeat from an agent.
|
||||
* Updates lastHeartbeat, capabilities (if provided), and transitions STALE agents back to LIVE.
|
||||
* Updates lastHeartbeat, routeIds (if provided), capabilities (if provided),
|
||||
* and transitions STALE agents back to LIVE.
|
||||
*
|
||||
* @return true if the agent is known, false otherwise
|
||||
*/
|
||||
public boolean heartbeat(String id, Map<String, Object> capabilities) {
|
||||
public boolean heartbeat(String id, List<String> routeIds, Map<String, Object> capabilities) {
|
||||
AgentInfo updated = agents.computeIfPresent(id, (key, existing) -> {
|
||||
Instant now = Instant.now();
|
||||
AgentInfo result = existing.withLastHeartbeat(now);
|
||||
if (routeIds != null && !routeIds.isEmpty()) {
|
||||
result = result.withRouteIds(List.copyOf(routeIds));
|
||||
}
|
||||
if (capabilities != null && !capabilities.isEmpty()) {
|
||||
result = result.withCapabilities(Map.copyOf(capabilities));
|
||||
}
|
||||
@@ -91,9 +95,9 @@ public class AgentRegistryService {
|
||||
return updated != null;
|
||||
}
|
||||
|
||||
/** Overload for callers without capabilities (backward compatibility). */
|
||||
/** Overload for callers without routeIds or capabilities (backward compatibility). */
|
||||
public boolean heartbeat(String id) {
|
||||
return heartbeat(id, null);
|
||||
return heartbeat(id, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user