diff --git a/scripts/dev-portal/index.html b/scripts/dev-portal/index.html index 505fe84c97..66bf651f92 100644 --- a/scripts/dev-portal/index.html +++ b/scripts/dev-portal/index.html @@ -449,12 +449,44 @@

No stacks running

} // All envs for the same worktree appear in a single card. - const groups = [...groupByWorktree(stacks).values()]; + const groups = groupByWorktree(stacks); const dupNames = duplicateNames( - groups.map(group => cardHeader(group).worktree), + [...groups.values()].map(group => cardHeader(group).worktree), ); - return `
${groups.map(group => renderWorktreeCard(group, dupNames)).join('')}
`; + return `
${[...groups.entries()].map(([key, group]) => renderWorktreeCard(key, group, dupNames)).join('')}
`; + } + + // Collapsed live cards, keyed like groupByWorktree. Persisted so the + // choice survives reloads; cards are expanded by default. + const COLLAPSED_STORAGE_KEY = 'hdx-dev-portal-collapsed'; + const collapsedStacks = new Set( + JSON.parse(localStorage.getItem(COLLAPSED_STORAGE_KEY) || '[]'), + ); + + function onStackHeaderClick(event, header) { + if (event.target.closest('a')) return; + const card = header.closest('.stack-card'); + const key = card.dataset.key; + const collapsed = !collapsedStacks.has(key); + if (collapsed) collapsedStacks.add(key); + else collapsedStacks.delete(key); + localStorage.setItem( + COLLAPSED_STORAGE_KEY, + JSON.stringify([...collapsedStacks]), + ); + card.classList.toggle('collapsed', collapsed); + card.querySelector('.services-table').hidden = collapsed; + card + .querySelector('.stack-toggle') + .setAttribute('aria-expanded', String(!collapsed)); + } + + function slotLabel(stacks) { + const slots = [...new Set(stacks.map(s => s.slot))].sort( + (a, b) => a - b, + ); + return `${slots.length > 1 ? 'Slots' : 'Slot'} ${slots.join(', ')}`; } // Group by full path so checkouts that share a folder name (a/hyperdx, @@ -487,8 +519,9 @@

No stacks running

return stacks.find(s => s.envType === 'dev') || stacks[0]; } - function renderWorktreeCard(stacks, dupNames) { + function renderWorktreeCard(key, stacks, dupNames) { const header = cardHeader(stacks); + const collapsed = collapsedStacks.has(key); const worktreePath = (stacks.find(s => s.worktreePath) || {}).worktreePath || ''; const devStack = stacks.find(s => s.envType === 'dev'); @@ -528,20 +561,24 @@

No stacks running

} return ` -
-
-
-
- ${escapeHtml(header.branch)} -
-
${escapeHtml(worktreeLabel(header.worktree, worktreePath, dupNames))}
-
+
+
+
${chUrl ? `Open ClickHouse` : ''} ${appUrl ? `Open App` : ''}
- +
@@ -917,7 +954,17 @@

Past Runs

const res = await fetch('/api/stacks'); if (!res.ok) throw new Error(`HTTP ${res.status}`); const stacks = await res.json(); + // Re-rendering replaces the toggle buttons, so restore keyboard focus. + const focusedKey = document.activeElement?.matches('.stack-toggle') + ? document.activeElement.closest('.stack-card').dataset.key + : null; contentEl.innerHTML = renderStacks(stacks); + if (focusedKey !== null) { + [...contentEl.querySelectorAll('.stack-card')] + .find(card => card.dataset.key === focusedKey) + ?.querySelector('.stack-toggle') + .focus(); + } errorEl.style.display = 'none'; } catch (err) { errorEl.textContent = `Failed to fetch stacks: ${err.message}`; diff --git a/scripts/dev-portal/styles.css b/scripts/dev-portal/styles.css index 72eb1bf213..8261eaf977 100644 --- a/scripts/dev-portal/styles.css +++ b/scripts/dev-portal/styles.css @@ -54,8 +54,8 @@ } body { - font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, - sans-serif; + font-family: + -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; @@ -321,6 +321,86 @@ body { .stack-header .stack-actions { display: flex; gap: 8px; + flex-shrink: 0; +} + +.stack-header-toggle { + cursor: pointer; + gap: 16px; + transition: background 0.1s; +} + +.stack-header-toggle:hover { + background: var(--row-hover); +} + +.stack-card.collapsed .stack-header { + border-bottom: none; +} + +.stack-toggle { + display: flex; + align-items: center; + gap: 10px; + min-width: 0; + padding: 0; + background: none; + border: none; + border-radius: 4px; + color: inherit; + font: inherit; + text-align: left; + cursor: pointer; +} + +.stack-toggle:focus-visible { + outline: 2px solid var(--accent); + outline-offset: 4px; +} + +.stack-toggle .chevron { + width: 16px; + height: 16px; + flex-shrink: 0; + color: var(--text-muted); +} + +.stack-card.collapsed .stack-toggle .chevron { + rotate: -90deg; +} + +@media (prefers-reduced-motion: no-preference) { + .stack-toggle .chevron { + transition: rotate 0.15s; + } +} + +.stack-title { + display: block; + min-width: 0; +} + +.stack-title-row { + display: flex; + align-items: center; + gap: 8px; + min-width: 0; +} + +.stack-header .worktree { + display: block; +} + +.slot-badge { + flex-shrink: 0; + font-size: 11px; + font-weight: 600; + font-family: 'SF Mono', 'Fira Code', monospace; + color: var(--text-muted); + background: var(--card-surface); + border: 1px solid var(--border); + padding: 1px 6px; + border-radius: 4px; } .stack-header .open-btn {
Service