fix: collect all support services before rendering sidebar (code review fix)

Agent-Logs-Url: https://github.com/naturallaw777/staging_alpha/sessions/4304350a-bc4f-4698-82b5-8ee28f0ad960

Co-authored-by: naturallaw777 <99053422+naturallaw777@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-04-03 18:02:06 +00:00
committed by GitHub
parent c6868b63bc
commit 02ae34dbd0

View File

@@ -172,17 +172,19 @@ async function apiFetch(path, options) {
function buildTiles(services, categoryLabels) { function buildTiles(services, categoryLabels) {
_servicesCache = services; _servicesCache = services;
var grouped = {}; var grouped = {};
var supportServices = [];
for (var i = 0; i < services.length; i++) { for (var i = 0; i < services.length; i++) {
var svc = services[i]; var svc = services[i];
// Support tiles go to the sidebar, not the main grid // Support tiles go to the sidebar, not the main grid
if (svc.category === "support" || svc.type === "support") { if (svc.category === "support" || svc.type === "support") {
renderSidebarSupport(svc); supportServices.push(svc);
continue; continue;
} }
var cat = svc.category || "other"; var cat = svc.category || "other";
if (!grouped[cat]) grouped[cat] = []; if (!grouped[cat]) grouped[cat] = [];
grouped[cat].push(svc); grouped[cat].push(svc);
} }
renderSidebarSupport(supportServices);
$tilesArea.innerHTML = ""; $tilesArea.innerHTML = "";
var orderedKeys = CATEGORY_ORDER.filter(function(k) { return grouped[k]; }); var orderedKeys = CATEGORY_ORDER.filter(function(k) { return grouped[k]; });
Object.keys(grouped).forEach(function(k) { Object.keys(grouped).forEach(function(k) {
@@ -208,21 +210,26 @@ function buildTiles(services, categoryLabels) {
} }
} }
function renderSidebarSupport(svc) { function renderSidebarSupport(supportServices) {
$sidebarSupport.innerHTML = ""; $sidebarSupport.innerHTML = "";
var btn = document.createElement("button"); for (var i = 0; i < supportServices.length; i++) {
btn.className = "sidebar-support-btn"; var svc = supportServices[i];
btn.innerHTML = var btn = document.createElement("button");
'<span class="sidebar-support-icon">🛟</span>' + btn.className = "sidebar-support-btn";
'<span class="sidebar-support-text">' + btn.innerHTML =
'<span class="sidebar-support-title">' + escHtml(svc.name || "Tech Support") + '</span>' + '<span class="sidebar-support-icon">🛟</span>' +
'<span class="sidebar-support-hint">Click for help</span>' + '<span class="sidebar-support-text">' +
'</span>'; '<span class="sidebar-support-title">' + escHtml(svc.name || "Tech Support") + '</span>' +
btn.addEventListener("click", function() { openSupportModal(); }); '<span class="sidebar-support-hint">Click for help</span>' +
$sidebarSupport.appendChild(btn); '</span>';
var hr = document.createElement("hr"); btn.addEventListener("click", function() { openSupportModal(); });
hr.className = "sidebar-divider"; $sidebarSupport.appendChild(btn);
$sidebarSupport.appendChild(hr); }
if (supportServices.length > 0) {
var hr = document.createElement("hr");
hr.className = "sidebar-divider";
$sidebarSupport.appendChild(hr);
}
} }
function buildTile(svc) { function buildTile(svc) {