From 32e2ae9b44e5cdacc954585e02a78ee8309db23a Mon Sep 17 00:00:00 2001 From: Bucky Schwarz Date: Tue, 29 Sep 2026 11:33:12 -0400 Subject: [PATCH] feat: add click-ui; change bug report anchor to use Link component --- .changeset/add-click-ui.md | 8 + agent_docs/code_style.md | 18 + packages/app/jest.config.js | 5 + packages/app/next.config.mjs | 3 + packages/app/package.json | 1 + packages/app/src/ThemeWrapper.tsx | 8 +- .../__mocks__/react-syntax-highlighter.tsx | 17 + .../components/ContactSupportText.module.scss | 4 + .../app/src/components/ContactSupportText.tsx | 13 +- .../components/__tests__/DBTimeChart.test.tsx | 12 +- .../__tests__/SpanLinkedFromSubpanel.test.tsx | 9 +- packages/app/src/setupTests.tsx | 19 +- packages/app/src/stories/ClickUI.stories.tsx | 58 + yarn.lock | 1270 ++++++++++++++++- 14 files changed, 1357 insertions(+), 88 deletions(-) create mode 100644 .changeset/add-click-ui.md create mode 100644 packages/app/src/__mocks__/react-syntax-highlighter.tsx create mode 100644 packages/app/src/components/ContactSupportText.module.scss create mode 100644 packages/app/src/stories/ClickUI.stories.tsx diff --git a/.changeset/add-click-ui.md b/.changeset/add-click-ui.md new file mode 100644 index 0000000000..90cd8b962d --- /dev/null +++ b/.changeset/add-click-ui.md @@ -0,0 +1,8 @@ +--- +'@hyperdx/app': patch +--- + +feat: add `@clickhouse/click-ui` as a dependency and mount `ClickUIProvider` +next to `MantineProvider`. The provider follows the HyperDX color mode and does +not persist its own theme. The "open an issue on GitHub" link in error messages +is the first component to use click-ui (`Link`). diff --git a/agent_docs/code_style.md b/agent_docs/code_style.md index e47bd958d0..d1e9ff1aff 100644 --- a/agent_docs/code_style.md +++ b/agent_docs/code_style.md @@ -406,6 +406,24 @@ The UI is built with **Mantine components**, but **colors and surfaces** should Mantine theme overrides in `packages/app/src/theme/**` may map Mantine’s scale to our palette; that does not replace using **`var(--color-...)`** in new styling where you need explicit color control. +## Click UI (incremental adoption) + +`@clickhouse/click-ui` is a dependency of `packages/app`. `ThemeWrapper` mounts +`ClickUIProvider` inside `MantineProvider` with `persistTheme={false}`, so it +follows the HyperDX color mode and never writes its own theme to localStorage. +Storybook and `renderWithMantine` in tests get the provider for free. + +- **Do**: Prefer a click-ui component over a new Mantine one when click-ui has + an equivalent for a simple primitive (`Link`, `Text`, `Title`, `Container`, + `Badge`, `Separator`, `Spacer`, `Icon`). Import from `@clickhouse/click-ui`. +- **Do not**: Mix both libraries inside one small component, and do not + replace working Mantine code outside the change you were asked to make. +- **Styling**: click-ui styles live in the `clickui` CSS cascade layer, so any + unlayered app or Mantine rule wins over them. Override `--click-*` variables + outside the layer if a token must change. +- **First use**: `packages/app/src/components/ContactSupportText.tsx` and the + `Click UI/Link` story in `packages/app/src/stories/ClickUI.stories.tsx`. + **Chart and visualization colors are a separate, more specific contract** — they have their own categorical, semantic, and heatmap palettes wired through `packages/app/src/utils.ts` helpers. Don't hard-code series colors or reuse `--color-text-*` for charts. See [`data_viz_colors.md`](./data_viz_colors.md) before touching anything that renders data. ## Refactoring diff --git a/packages/app/jest.config.js b/packages/app/jest.config.js index fb973f3aa6..c9b6a4a561 100644 --- a/packages/app/jest.config.js +++ b/packages/app/jest.config.js @@ -25,6 +25,11 @@ module.exports = { '^ky$': '/src/__mocks__/ky-universal.ts', '^react-markdown$': '/src/__mocks__/react-markdown.tsx', '^remark-gfm$': '/src/__mocks__/remark-gfm.ts', + '^react-syntax-highlighter$': + '/src/__mocks__/react-syntax-highlighter.tsx', + // @clickhouse/click-ui depends on ESM-only lodash-es; lodash has the same API. + '^lodash-es$': 'lodash', + '^lodash-es/(.*)$': 'lodash/$1', }, setupFilesAfterEnv: ['/src/setupTests.tsx'], // Coverage floors are scoped to hooks/ and utils/ only — the genuinely diff --git a/packages/app/next.config.mjs b/packages/app/next.config.mjs index 4707feeaaa..849eae6ba0 100644 --- a/packages/app/next.config.mjs +++ b/packages/app/next.config.mjs @@ -94,6 +94,9 @@ const nextConfig = { // when running dev and E2E simultaneously (e.g. NEXT_DIST_DIR=.next-e2e) ...(process.env.NEXT_DIST_DIR ? { distDir: process.env.NEXT_DIST_DIR } : {}), reactCompiler: true, + // click-ui ships per-component CSS imports from node_modules, which Next + // rejects as global CSS unless the package is transpiled. + transpilePackages: ['@clickhouse/click-ui'], basePath: basePath, env: { // Ensures bundler-time replacements for client/server code that references this env var diff --git a/packages/app/package.json b/packages/app/package.json index 92d15fa9aa..91d99966cd 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -26,6 +26,7 @@ "storybook:build": "storybook build" }, "dependencies": { + "@clickhouse/click-ui": "^0.12.0", "@codemirror/autocomplete": "^6.0.0", "@codemirror/lang-json": "^6.0.1", "@codemirror/lang-sql": "^6.7.0", diff --git a/packages/app/src/ThemeWrapper.tsx b/packages/app/src/ThemeWrapper.tsx index fc47372faf..628df53647 100644 --- a/packages/app/src/ThemeWrapper.tsx +++ b/packages/app/src/ThemeWrapper.tsx @@ -1,4 +1,5 @@ import React from 'react'; +import { ClickUIProvider } from '@clickhouse/click-ui'; import { MantineProvider, MantineThemeOverride } from '@mantine/core'; import { Notifications } from '@mantine/notifications'; @@ -36,8 +37,11 @@ export const ThemeWrapper = ({ return ( - - {children} + {/* HyperDX user preferences determine the color mode, so click-ui should not persist preferences to localstorage. */} + + + {children} + ); }; diff --git a/packages/app/src/__mocks__/react-syntax-highlighter.tsx b/packages/app/src/__mocks__/react-syntax-highlighter.tsx new file mode 100644 index 0000000000..2b312e2b20 --- /dev/null +++ b/packages/app/src/__mocks__/react-syntax-highlighter.tsx @@ -0,0 +1,17 @@ +import React from 'react'; + +// @clickhouse/click-ui's barrel export pulls in react-syntax-highlighter for +// CodeBlock, whose prism build depends on ESM-only hastscript that Jest cannot +// parse. Unit tests never render a click-ui CodeBlock, so this stub only needs +// the surface the click-ui module touches at import time. +function Highlighter({ children }: { children?: React.ReactNode }) { + return
{children}
; +} + +Highlighter.registerLanguage = () => undefined; + +export const Light = Highlighter; +export const Prism = Highlighter; +export const PrismLight = Highlighter; +export const createElement = () => null; +export default Highlighter; diff --git a/packages/app/src/components/ContactSupportText.module.scss b/packages/app/src/components/ContactSupportText.module.scss new file mode 100644 index 0000000000..32e1ef7502 --- /dev/null +++ b/packages/app/src/components/ContactSupportText.module.scss @@ -0,0 +1,4 @@ +// The link should look like normal font instead of click-ui's link font. +.inlineLink { + font: inherit; +} diff --git a/packages/app/src/components/ContactSupportText.tsx b/packages/app/src/components/ContactSupportText.tsx index a8a8aecbf0..190bf47e98 100644 --- a/packages/app/src/components/ContactSupportText.tsx +++ b/packages/app/src/components/ContactSupportText.tsx @@ -1,5 +1,9 @@ +import { Link } from '@clickhouse/click-ui'; + import { IS_OSS } from '@/config'; +import styles from './ContactSupportText.module.scss'; + const GH_LINK = 'https://github.com/hyperdxio/hyperdx/issues'; export const ContactSupportText = () => { @@ -7,9 +11,14 @@ export const ContactSupportText = () => { return ( Please open an issue on{' '} - + GitHub - + . ); diff --git a/packages/app/src/components/__tests__/DBTimeChart.test.tsx b/packages/app/src/components/__tests__/DBTimeChart.test.tsx index e1b6e9543a..3f7ab432b6 100644 --- a/packages/app/src/components/__tests__/DBTimeChart.test.tsx +++ b/packages/app/src/components/__tests__/DBTimeChart.test.tsx @@ -1,6 +1,4 @@ import React from 'react'; -import { MantineProvider } from '@mantine/core'; -import { Notifications } from '@mantine/notifications'; import { screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; @@ -307,8 +305,7 @@ describe('DBTimeChart', () => { // survive — this also guards against dateRange being reintroduced into // queryShapeIdentity, which would make live-range ticks re-cap the chart. rerender( - - + { ], }} /> - , + , ); // The opt-in survives: no series are re-hidden, so the affordance stays @@ -349,10 +346,9 @@ describe('DBTimeChart', () => { // Change the query shape (a positive seriesLimit below GROUP_COUNT keeps // series hidden), which should reset the opt-in and re-show the affordance. rerender( - - + - , + , ); expect( diff --git a/packages/app/src/components/__tests__/SpanLinkedFromSubpanel.test.tsx b/packages/app/src/components/__tests__/SpanLinkedFromSubpanel.test.tsx index 6fd72b7fef..a2f36c28fb 100644 --- a/packages/app/src/components/__tests__/SpanLinkedFromSubpanel.test.tsx +++ b/packages/app/src/components/__tests__/SpanLinkedFromSubpanel.test.tsx @@ -17,9 +17,12 @@ describe('SpanLinkedFromSubpanel', () => { const { container } = renderWithMantine( , ); - // The Mantine provider injects