fix(central-ui): Debug View reconnect guards the stored instance; drop select-era sort; deep-link-in-area test

Three final-review findings on the two picker pages:

1. DebugView's localStorage auto-reconnect restored the stored instance id with
   no membership check, where the ?instanceId= path has one — a stored instance
   that is no longer Enabled (or was deleted, or moved sites) is filtered out of
   the list the picker is handed, so the field rendered blank while the page held
   a non-zero id and auto-connected to it anyway. The guard now mirrors the
   deep-link path: forget the stored instance id, tell the operator, and leave the
   site selected and loaded so they can pick again.
2. FlowDebugger's _instances kept an OrderBy(UniqueName) from the flat <select>
   era; InstanceTreeBuilder sorts areas and instances itself.
3. The deep-link test is joined by one where the instance sits two areas deep, so
   the field text is pinned to resolve from the flat list with the panel never
   opened.

Claude-Session: https://claude.ai/code/session_01NcMG6xXdsJbmD2wYAgkK29
This commit is contained in:
Joseph Doherty
2026-09-08 10:01:22 -04:00
parent 82f6fb949e
commit 52726cf30d
4 changed files with 77 additions and 5 deletions
@@ -421,15 +421,31 @@
{
_selectedSiteId = siteId;
await LoadInstancesForSite();
// Membership guard, mirroring the ?instanceId= path above. A stored instance that
// has since been disabled (or deleted, or moved to another site) is not in the list
// the picker was handed, so it renders a blank field while the page holds a non-zero
// id and auto-connects to it anyway. Forget the stored instance instead — the site
// stays selected and loaded, so the operator just picks again.
var stored = _siteInstances.FirstOrDefault(i => i.Id == instanceId);
if (stored == null)
{
await JS.InvokeVoidAsync("localStorage.removeItem", "debugView.instanceId");
_toast.ShowInfo(
"The instance from your previous session is no longer available for debug streaming.",
autoDismissMs: 8000);
StateHasChanged();
return;
}
_selectedInstanceId = instanceId;
_connectedFromStorage = true;
StateHasChanged();
await Connect();
// Auto-reconnect notice — the user didn't initiate this connection.
var inst = _siteInstances.FirstOrDefault(i => i.Id == instanceId);
_toast.ShowInfo(
$"Auto-reconnected to {inst?.UniqueName ?? "instance"} from previous session.",
$"Auto-reconnected to {stored.UniqueName} from previous session.",
autoDismissMs: 8000);
}
}
@@ -447,9 +447,9 @@ public partial class FlowDebugger : ComponentBase, IDisposable
return;
}
_instances = (await TemplateEngineRepository.GetInstancesBySiteIdAsync(_selectedSiteId))
.OrderBy(i => i.UniqueName, StringComparer.OrdinalIgnoreCase).ToList();
// The picker nests these itself (InstanceTreeBuilder), so order does not matter here.
// Neither list is sorted here: the picker nests and orders both itself
// (InstanceTreeBuilder). The OrderBy this replaces dated from the flat <select>.
_instances = (await TemplateEngineRepository.GetInstancesBySiteIdAsync(_selectedSiteId)).ToList();
_areas = (await TemplateEngineRepository.GetAreasBySiteIdAsync(_selectedSiteId)).ToList();
}
finally