Skip to content

chore(dev-portal): make stack cards collapsible and show slot number - #3827

Merged
kodiakhq[bot] merged 2 commits into
mainfrom
dev-portal-collapse
Nov 25, 2026
Merged

kodiakhq[bot] merged 2 commits into
mainfrom
dev-portal-collapse

Conversation

@karl-power

@karl-power karl-power commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Make each worktree card on the dev portal's Live tab collapsible and show its dev slot number in the header.

  • Clicking a card header toggles its services table; the "Open ClickHouse" and "Open App" links still open without toggling.
  • The branch and worktree name sit in a <button aria-expanded> with a chevron, so the toggle works with the keyboard and screen readers.
  • Collapsed state is kept across the 3s auto-refresh and saved in localStorage, so it survives page reloads. Cards start expanded.
  • Keyboard focus on a toggle is restored after each auto-refresh re-render.
  • The header shows a slot badge (Slot 3), or Slots 3, 12 if a worktree's environments run on different slots.

Screenshots or video

Screenshot 2026-11-25 at 11 33 42

@karl-power
karl-power requested a review from a team as a code owner November 25, 2026 10:36
@changeset-bot

changeset-bot Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: b52cda4

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel

vercel Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
hyperdx-oss Ready Ready Preview Nov 25, 2026 11:22am UTC
hyperdx-storybook Ready Ready Preview Nov 25, 2026 11:22am UTC

Request Review

@github-actions github-actions Bot added the review/tier-2 Low risk — AI review + quick human skim label Nov 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔵 Tier 2 — Low Risk

Small, isolated change with no API route or data model modifications.

Why this tier:

  • Standard feature/fix — introduces new logic or modifies core functionality

Review process: AI review + quick human skim (target: 5–15 min). Reviewer validates AI assessment and checks for domain-specific concerns.
SLA: Resolve within 4 business hours.

Stats
  • Production files changed: 2
  • Production lines changed: 157
  • Branch: dev-portal-collapse
  • Author: karl-power

To override this classification, remove the review/tier-2 label and apply a different review/tier-* label. Manual overrides are preserved on subsequent pushes.

@github-actions

Copy link
Copy Markdown
Contributor

Duplicate code analysis

No new duplicate code introduced by this PR.


jscpd compared this branch against origin/main
across app, api and common-utils. Only new clones are listed; the codebase
currently holds 107 in total (1.12%).
Run yarn dupes locally to reproduce, or yarn dupes:all for the full picture.

[...contentEl.querySelectorAll('.stack-card')]
.find(card => card.dataset.key === focusedKey)
?.querySelector('.stack-toggle')
.focus();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 P2 — Restoring focus every 3s scrolls the page back to the toggle

.focus() scrolls the element into view by default. Say a user clicks a card header (Chrome and Firefox give the button focus) and then scrolls down to another card or the log rows. The next auto-refresh will jump the page back to that toggle, and so will every one after it. Call .focus({ preventScroll: true }) instead.

Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond

</div>
<div class="stack-card${collapsed ? ' collapsed' : ''}" data-key="${escapeHtml(key)}">
<div class="stack-header stack-header-toggle" onclick="onStackHeaderClick(event, this)">
<button type="button" class="stack-toggle" aria-expanded="${!collapsed}">

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 P2 — Branch and worktree text can no longer be selected or copied

The branch name and worktree path were a plain <div>. Now they sit inside a <button> within a header that toggles on click. Browsers don't let you drag-select text inside a button, and double-clicking the branch name to select it toggles the card twice. Put only the chevron (with an aria-label) in the toggle button, or keep the title text outside it and stop toggling when getSelection() is non-empty.

Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond

// 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(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 P2 — A malformed stored value throws at top level and stops the whole portal script

new Set(JSON.parse(...)) runs at script load. If the stored value isn't valid JSON or isn't an array (e.g. {}), it throws and everything after it in the script never runs: refresh(), the interval, the toggles. Wrap the read in try/catch and fall back to [] when Array.isArray fails.

Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond

const collapsed = !collapsedStacks.has(key);
if (collapsed) collapsedStacks.add(key);
else collapsedStacks.delete(key);
localStorage.setItem(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 P2 — Collapsed keys are never pruned, so removed worktrees stay collapsed

Entries are only removed when a user expands a card, so old worktree paths stay in localStorage for good. If someone collapses a card, tears down that worktree, and later recreates one at the same path, its card comes back already collapsed. When rendering, prune collapsedStacks down to the keys present in groupByWorktree(stacks), but skip pruning when the list is empty so a brief stack-less refresh doesn't wipe it.

Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond

@github-actions

Copy link
Copy Markdown
Contributor

PR Review

If you are a coding agent acting for the author, read this first.
Nothing below blocks merge automatically; a maintainer decides. What they will expect:

  • 🔴 P0/P1 in code this PR adds or changes: fix before asking for review.
  • 🟡 P2 in code this PR changes: your call. Fix if small, otherwise reply.
  • 🔵 P3 is collapsed at the bottom: nobody needs to act on it before merge.
  • Anything about surrounding code, or asking you to widen the change (hoist a helper,
    dedupe with another file, fix other call sites): never fix here, whatever the
    priority. Reply with one sentence; if it is P0, say so plainly so a human sees it.

One commit per review round. After two rounds, stop and ask a maintainer to review
scope rather than addressing more automated findings. Full rule: AGENTS.md.

5 finding(s): 🔴 0 P0/P1 · 🟡 4 P2 · 🔵 1 P3

4 posted as inline comment(s) on the changed lines. 1 P3 folded at the bottom.

🔵 1 P3 — no action needed before merge
  • 🔵 P3 scripts/dev-portal/index.html:467 — Second collapse mechanism added next to the existing history-card one → The History tab already has collapsible worktree cards (historyExpanded, toggleHistoryCard, and renderHistoryWorktreeCard with ▶/▼ and .history-card-body.collapsed, in the same file). This PR adds a separate implementation with different markup (an SVG chevron in a button), different state handling (persisted, toggled in the DOM), and different CSS. The two tabs now look and behave differently. Factor out one shared collapsible-card helper and use it for both tabs, or move the history cards onto the new pattern.

Priority comes from a separate grading pass over the finished review. P3 is folded here instead of posted inline. No finding blocks merge automatically; a maintainer decides.

@github-actions

Copy link
Copy Markdown
Contributor

Deep Review

✅ No critical issues found. This is a self-contained, human-facing dev-portal change (vanilla JS in index.html + CSS). Correctness verified the focus-restore ?. short-circuit, the data-key escape round-trip, the anchor-click guard, aria-expanded, and the [hidden] attribute all behave as intended. One recommended hardening item and a handful of nits follow.

🟡 P2 — recommended

  • scripts/dev-portal/index.html:464 — The persisted collapsed set is built at script load with new Set(JSON.parse(localStorage.getItem(COLLAPSED_STORAGE_KEY) || '[]')) and no guard, so a stored value that is not a JSON array (corrupt/truncated string, or a valid-but-non-iterable scalar/object) throws at top level and aborts the rest of the inline script — the auto-refresh loop, Escape handler, and autoscroll init never run, leaving a silently blank portal with nothing shown in errorEl.
    • Fix: Wrap the read in try/catch, verify Array.isArray(parsed) before constructing the Set, and default to an empty Set on failure.
    • adversarial, correctness, testing
🔵 P3 nitpicks (5)
  • scripts/dev-portal/styles.css:390 — The added .stack-header .worktree rule (only display: block) duplicates the selector already defined at styles.css:315.
    • Fix: Delete the new rule and add display: block; to the existing block at line 315.
  • scripts/dev-portal/index.html:472 — Keys are added to collapsedStacks on collapse but never pruned when a worktree disappears, so the persisted array grows unbounded and a later worktree reusing the same path renders unexpectedly collapsed.
    • Fix: In renderStacks, intersect collapsedStacks with the currently-present keys and re-persist the pruned set.
  • scripts/dev-portal/index.html:474 — collapsedStacks is mutated before localStorage.setItem, so if setItem throws (private mode/quota) the handler aborts before the DOM toggle and the card only appears to toggle ~3s later on the next refresh.
    • Fix: Apply the DOM toggle first, then call setItem inside a try/catch.
  • scripts/dev-portal/index.html:966 — Focus restoration calls .focus() without { preventScroll: true }, so a keyboard user who focuses a toggle then scrolls away is yanked back to it on each 3s refresh.
    • Fix: Pass { preventScroll: true } to the .focus() call.
  • scripts/dev-portal/index.html:958 — The new focus restoration covers only .stack-toggle; other card controls (the Open links, Logs buttons, clickable rows) still lose focus to <body> on each refresh — a pre-existing limitation the new restore does not extend to.
    • Fix: Capture a more general focus descriptor (card key plus an in-card selector/index) and restore whichever element was active.

Reviewers (9): correctness, testing, maintainability, project-standards, agent-native, learnings-researcher, julik-frontend-races, adversarial, previous-comments.

Testing gaps: scripts/dev-portal/ has no test harness (existing node:test covers only the slot shell scripts), and the inline, non-exported logic is not unit-testable as written; the new slotLabel singular/plural, collapse persistence, and focus restoration ship without coverage — advisory only given the absent infra.

No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond

@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

E2E Test Results

✅ All tests passed • 477 passed • 1 skipped • 1096s

Status Count
✅ Passed 477
❌ Failed 0
⚠️ Flaky 11
⏭️ Skipped 1

Tests ran across 4 shards in parallel.

View full report →

@kodiakhq
kodiakhq Bot merged commit e9c89eb into main Nov 25, 2026
28 checks passed
@kodiakhq
kodiakhq Bot deleted the dev-portal-collapse branch November 25, 2026 11:23

This branch was successfully deployed

2 active deployments
Preview – hyperdx-oss — b52cda48 Deployed Nov 25, 2026 by vercel[bot]
Preview – hyperdx-storybook — b52cda48 Deployed Nov 25, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge review/tier-2 Low risk — AI review + quick human skim

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants