Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/debug-info-clickhouse-version.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hyperdx/app': patch
---

feat: include each connection's ClickHouse server version in the "Copy debug info" report
21 changes: 21 additions & 0 deletions packages/app/src/__tests__/hdxDebug.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,27 @@ describe('report identity + features', () => {
});
});

describe('report clickhouse lines', () => {
it('omits clickhouse lines until versions are set', () => {
expect(reportFor(loadHdxDebug())).not.toContain('clickhouse:');
});

it('lists each connection after the backend line', () => {
const mod = loadHdxDebug();
mod.setHdxClickHouseVersions([
{ name: 'Local', version: '26.10.3.7' },
{ name: 'Demo', version: undefined },
]);
const lines = reportFor(mod).split('\n');

expect(lines.slice(1, 4)).toEqual([
'backend: unknown',
'clickhouse: Local 26.10.3.7',
'clickhouse: Demo unknown',
]);
});
});

describe('report session line', () => {
it('reports N/A until the RUM SDK has a session', () => {
const report = reportFor(loadHdxDebug());
Expand Down
19 changes: 19 additions & 0 deletions packages/app/src/components/AppNav/AppNav.components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ import {
} from '@tabler/icons-react';

import { IS_LOCAL_MODE } from '@/config';
import { useConnections } from '@/connection';
import { setHdxClickHouseVersions } from '@/hdxDebug';
import { getMetadata } from '@/metadata';
import { copyTextToClipboard } from '@/utils/clipboard';

import { HelpSparkle } from './HelpSparkle';
Expand Down Expand Up @@ -197,6 +200,22 @@ export const AppNavUserMenu = ({

const AppNavVersionItem = ({ version }: { version?: string }) => {
const [copied, setCopied] = React.useState(false);
const { data: connections } = useConnections();

// Fetched when the Help menu opens rather than on click: awaiting before the
// clipboard write would drop the user gesture Safari requires for it.
// getServerVersion is cached per connection, so this is usually free.
React.useEffect(() => {

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 — ClickHouse versions only load once the Help menu has been opened, so window.hdx.report()/copy() leave them out, and a fast first click can too

Move this effect into AppNav.tsx, next to the setHdxIdentity effect (~line 224), which is always mounted. Right now it sits in AppNavVersionItem, which only mounts while Menu.Dropdown is open. So the console API from installHdxDebug (packages/app/src/hdxDebug.ts) has no clickhouse: lines until the menu has been opened at least once. Also, Promise.all only writes once the slowest connection answers, so clicking Copy right after opening the menu (cache still cold) gives a report with no ClickHouse lines at all. Write each connection's result as it arrives, or fetch on nav mount, so one slow connection doesn't hold back the others.

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

if (!connections) return;
void Promise.all(
connections.map(async c => ({
name: c.name,
version: (
await getMetadata().getServerVersion({ connectionId: c.id })
)?.join('.'),
})),
).then(setHdxClickHouseVersions);
}, [connections]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Debug copy can miss versions

Low Severity

Copy debug info reads clickhouseVersions immediately, while the Help-menu effect still fetches them. The first copy can omit the clickhouse: lines when getServerVersion is not already cached. In-flight results also write module state with no cancellation, so an older request can replace newer connection data.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 2950c34. Configure here.


return (
<Menu.Item
Expand Down
11 changes: 11 additions & 0 deletions packages/app/src/hdxDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import { copyTextToClipboard } from '@/utils/clipboard';
// session id, and a one-shot `report()` that bundles it all into text to drop
// straight into a bug report.

type HdxClickHouseVersion = { name: string; version?: string };

// Device Info
type HdxDevice = {
screen: string;
Expand Down Expand Up @@ -77,6 +79,7 @@ let cachedServerVersion: string | null = null;
let userId: string | undefined;
let teamId: string | undefined;
let dynamicFeatures: Record<string, boolean> = {};
let clickhouseVersions: HdxClickHouseVersion[] = [];

// Only env-configurable flags are worth reporting — the hardcoded-true/false
// ones (k8s dashboard, metrics, sessions, materialized views) are the same in
Expand Down Expand Up @@ -132,6 +135,11 @@ export function setHdxIdentity(next: {
dynamicFeatures = next.features ?? {};
}

/** Record the ClickHouse server version of each connection (see AppNav). */
export function setHdxClickHouseVersions(next: HdxClickHouseVersion[]): void {
clickhouseVersions = next;
}

// Null until the RUM SDK has started, which needs /api/config and never happens
// in local mode.
function sessionId(): string | undefined {
Expand Down Expand Up @@ -178,6 +186,9 @@ function buildReport(): string {
const lines = [
`frontend: ${APP_VERSION}`,
`backend: ${cachedServerVersion || 'unknown'}`,
...clickhouseVersions.map(
c => `clickhouse: ${c.name} ${c.version ?? 'unknown'}`,
),
`mode: ${IS_LOCAL_MODE ? 'local' : isOss ? 'oss' : 'cloud'}${
IS_CLICKHOUSE_BUILD ? ' (clickstack)' : ''
}`,
Expand Down
71 changes: 63 additions & 8 deletions scripts/dev-portal/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,17 @@ <h1>
<button class="tab" id="tab-history" onclick="switchTab('history')">
History
</button>
<button
type="button"
class="toggle-all-btn"
id="toggle-all-btn"
aria-expanded="true"
hidden
onclick="toggleAllStacks()"
>
<span class="expand">Expand all</span>
<span class="collapse">Collapse all</span>
</button>
</div>

<div id="error-banner" class="error-banner"></div>
Expand Down Expand Up @@ -184,6 +195,7 @@ <h3>
const logTitle = document.getElementById('log-title');
const logSlotLabel = document.getElementById('log-slot-label');
const logStreamBadge = document.getElementById('log-stream-badge');
const toggleAllBtn = document.getElementById('toggle-all-btn');

let activeTab = 'live';
let currentLogSlot = null;
Expand Down Expand Up @@ -464,31 +476,70 @@ <h2>No stacks running</h2>
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);
function saveCollapsedStacks() {
localStorage.setItem(
COLLAPSED_STORAGE_KEY,
JSON.stringify([...collapsedStacks]),
);
}

function setStackCollapsed(card, collapsed) {
if (collapsed) collapsedStacks.add(card.dataset.key);
else collapsedStacks.delete(card.dataset.key);
card.classList.toggle('collapsed', collapsed);
card.querySelector('.services-table').hidden = collapsed;
card
.querySelector('.stack-toggle')
.setAttribute('aria-expanded', String(!collapsed));
}

function onStackHeaderClick(event, header) {
if (event.target.closest('a')) return;
const card = header.closest('.stack-card');
setStackCollapsed(card, !card.classList.contains('collapsed'));
saveCollapsedStacks();
updateToggleAllButton();
}

// Reads "Collapse all" only when every card is open; when some are
// collapsed it expands them all.
function updateToggleAllButton() {
const cards = [...contentEl.querySelectorAll('.stack-card')];
toggleAllBtn.hidden = activeTab !== 'live' || cards.length === 0;
toggleAllBtn.setAttribute(
'aria-expanded',
String(cards.every(card => !card.classList.contains('collapsed'))),
);
}

function toggleAllStacks() {
const collapse = toggleAllBtn.getAttribute('aria-expanded') === 'true';
for (const card of contentEl.querySelectorAll('.stack-card')) {
setStackCollapsed(card, collapse);
}
saveCollapsedStacks();
updateToggleAllButton();
}

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(', ')}`;
}

function clickhouseVersionLabel(stacks) {
const versions = [
...new Set(
stacks
.flatMap(s => s.services)
.filter(svc => svc.name === 'clickhouse' && svc.version)
.map(svc => svc.version),
),
];
return versions.length ? `ClickHouse ${versions.join(', ')}` : null;
}

// Group by full path so checkouts that share a folder name (a/hyperdx,
// b/hyperdx) get separate cards. Items with no known path fall back to
// their folder name.
Expand Down Expand Up @@ -522,6 +573,7 @@ <h2>No stacks running</h2>
function renderWorktreeCard(key, stacks, dupNames) {
const header = cardHeader(stacks);
const collapsed = collapsedStacks.has(key);
const chVersion = clickhouseVersionLabel(stacks);
const worktreePath =
(stacks.find(s => s.worktreePath) || {}).worktreePath || '';
const devStack = stacks.find(s => s.envType === 'dev');
Expand Down Expand Up @@ -568,7 +620,8 @@ <h2>No stacks running</h2>
<span class="stack-title">
<span class="stack-title-row">
<span class="branch">${escapeHtml(header.branch)}</span>
<span class="slot-badge">${slotLabel(stacks)}</span>
<span class="meta-badge">${slotLabel(stacks)}</span>
${chVersion ? `<span class="meta-badge">${escapeHtml(chVersion)}</span>` : ''}
</span>
<span class="worktree" title="${escapeHtml(worktreePath)}">${escapeHtml(worktreeLabel(header.worktree, worktreePath, dupNames))}</span>
</span>
Expand Down Expand Up @@ -656,6 +709,7 @@ <h2>No stacks running</h2>
historyEl.style.display = '';
refreshHistory();
}
updateToggleAllButton();
}

// --- History rendering ---
Expand Down Expand Up @@ -959,6 +1013,7 @@ <h2>Past Runs</h2>
? document.activeElement.closest('.stack-card').dataset.key
: null;
contentEl.innerHTML = renderStacks(stacks);
updateToggleAllButton();
if (focusedKey !== null) {
[...contentEl.querySelectorAll('.stack-card')]
.find(card => card.dataset.key === focusedKey)
Expand Down
12 changes: 12 additions & 0 deletions scripts/dev-portal/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,17 @@ function parseContainerLabels(container) {
return labels;
}

// "clickhouse/clickhouse-server:26.10.3.7-alpine" -> "26.10.3.7". Tags that
// aren't a version (latest, head) are returned as-is. docker ps shows an image
// ID instead of a name when the tag was removed or re-pointed.
function imageVersion(image) {
const name = (image || '').split('@')[0].split('/').pop();
if (name.startsWith('sha256:')) return null;
const tag = name.includes(':') ? name.slice(name.indexOf(':') + 1) : '';
const match = tag.match(/^\d+(\.\d+)*/);
return match ? match[0] : tag || null;
}

function parsePortMappings(portsStr) {
// Ports look like: "0.0.0.0:30589->8123/tcp, 0.0.0.0:30689->9000/tcp"
const mappings = [];
Expand Down Expand Up @@ -319,6 +330,7 @@ async function buildDashboardData() {
port: mainPort,
url: labels['hdx.dev.url'] || null,
ports,
version: imageVersion(container.Image),
containerId: container.ID,
uptime: container.RunningFor || '',
});
Expand Down
51 changes: 44 additions & 7 deletions scripts/dev-portal/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
--table-border: rgba(48, 54, 61, 0.5);
--modal-backdrop: rgba(0, 0, 0, 0.6);
--hover-overlay: rgba(255, 255, 255, 0.05);
/* Pill text, at least 4.5:1 against the pill's tinted background */
--pill-text: #c1c2c5;
--pill-green: #25e2a5;
--pill-yellow: #efb118;
--pill-blue: #79c0ff;
}

:root[data-theme='light'] {
Expand All @@ -45,6 +50,10 @@
--table-border: rgba(0, 0, 0, 0.08);
--modal-backdrop: rgba(0, 0, 0, 0.3);
--hover-overlay: rgba(0, 0, 0, 0.05);
--pill-text: #495057;
--pill-green: #06694c;
--pill-yellow: #8a5100;
--pill-blue: #154f8e;
}

* {
Expand Down Expand Up @@ -280,17 +289,17 @@ body {

.env-badge.dev {
background: rgba(37, 226, 165, 0.15);
color: var(--accent);
color: var(--pill-green);
}

.env-badge.e2e {
background: rgba(88, 166, 255, 0.15);
color: #58a6ff;
color: var(--pill-blue);
}

.env-badge.int {
background: rgba(239, 177, 24, 0.15);
color: var(--yellow);
color: var(--pill-yellow);
}

.services-table tr.env-separator td {
Expand Down Expand Up @@ -391,12 +400,12 @@ body {
display: block;
}

.slot-badge {
.meta-badge {
flex-shrink: 0;
font-size: 11px;
font-weight: 600;
font-family: 'SF Mono', 'Fira Code', monospace;
color: var(--text-muted);
color: var(--pill-text);
background: var(--card-surface);
border: 1px solid var(--border);
padding: 1px 6px;
Expand Down Expand Up @@ -482,12 +491,12 @@ body {

.type-badge.docker {
background: rgba(37, 226, 165, 0.12);
color: var(--accent);
color: var(--pill-green);
}

.type-badge.local {
background: rgba(239, 177, 24, 0.12);
color: var(--yellow);
color: var(--pill-yellow);
}

.log-btn {
Expand Down Expand Up @@ -583,6 +592,34 @@ body {
border-bottom-color: var(--accent);
}

.toggle-all-btn {
margin-left: auto;
align-self: center;
background: none;
border: 1px solid var(--border);
color: var(--text-muted);
padding: 4px 10px;
border-radius: 4px;
font-size: 12px;
cursor: pointer;
transition: all 0.15s;
}

.toggle-all-btn:hover {
color: var(--text);
border-color: var(--text-muted);
}

.toggle-all-btn:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 2px;
}

.toggle-all-btn[aria-expanded='true'] .expand,
.toggle-all-btn[aria-expanded='false'] .collapse {
display: none;
}

/* --- History --- */
.history-header {
display: flex;
Expand Down
Loading