Repository navigation
feat(app): make content font size configurable - #3166
Conversation
Log/trace table text was fixed at 12px, so the only way to make it bigger was browser zoom, which scales the chrome too. Add a contentFontSize user preference (sm/md/lg, defaulting to the current sizes) that writes --hdx-content-font-size and --hdx-content-font-size-compact on <html>, and read those vars from the content surfaces: search results table, data tables, expanded row JSON, and chart axes, legends and tooltips. Co-authored-by: Mike Shi <mike@hyperdx.io>
🦋 Changeset detectedLatest commit: 5a6ee92 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
[Medium impact] The PR appears safe to merge within its agreed scope, with no new blocking findings. SummaryAdds a saved content font-size setting while keeping Small as the default.
|
E2E Test Results✅ All tests passed • 429 passed • 1 skipped • 1346s
Tests ran across 4 shards in parallel. |
At the large content font size the timestamp and service columns truncated, because their default widths are px constants sized for 12px text. Scale the defaults by the font ratio; widths the user dragged to are left untouched. Co-authored-by: Mike Shi <mike@hyperdx.io>
Review feedback. The y-axis width and the bar chart's rotated-label height are character budgets measured at the default tick font, so at medium/large the widest tick labels clipped. Scale them by the same ratio, and narrow the preference Select's value with a type guard instead of asserting it. Co-authored-by: Mike Shi <mike@hyperdx.io>
🟡 Tier 3 — StandardIntroduces new logic, modifies core functionality, or touches areas with non-trivial risk. Why this tier:
Review process: Full human review — logic, architecture, edge cases. Stats
|
Deep ReviewConfigurable content font-size preference ( ✅ No critical issues found. 🟡 P2 — recommended
🔵 P3 nitpicks (4)
Reviewers (8): correctness, testing, maintainability, project-standards, kieran-typescript, previous-comments, agent-native, learnings-researcher. Testing gaps:
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 |
| } = useUserPreferences(); | ||
|
|
||
| const size = contentFontSize ?? DEFAULT_CONTENT_FONT_SIZE; | ||
| const { base, compact } = CONTENT_FONT_SIZES[size]; |
There was a problem hiding this comment.
🟠 major — useContentFontSize destructures CONTENT_FONT_SIZES[size] without validating the persisted value, so a bad stored value white-screens the app
contentFontSize comes straight out of localStorage — isUserPreferences (line 51) only validates colorMode, so any other string survives the read. With {"colorMode":"dark","contentFontSize":"xl"} in hdx-user-preferences (a rollback from a future build that adds a size, or a hand-edited/corrupt entry), CONTENT_FONT_SIZES['xl'] is undefined and destructuring { base, compact } throws inside AppContent (pages/_app.tsx:98) — the whole app fails to render and the user can't reach the preferences modal to undo it. Apply the guard that already exists: const size = contentFontSize && isContentFontSize(contentFontSize) ? contentFontSize : DEFAULT_CONTENT_FONT_SIZE; (same read-time validation pattern as isValidThemeName in packages/app/src/theme/index.ts:225).
Nothing blocks merge automatically, but a maintainer will expect this fixed if it is a real defect in code this PR changes. If it is about surrounding code, reply and say so instead of patching. Do not widen the PR. How to respond
| <Group wrap="nowrap" gap={0} align="center"> | ||
| {!header.column.getCanSort() ? ( | ||
| <Text truncate="end" size="xs" flex="1"> | ||
| <Text truncate="end" fz="var(--hdx-content-font-size)" flex="1"> |
There was a problem hiding this comment.
🔵 minor — Swapping size="xs" for fz drops Mantine's xs line-height, changing header rows at the default setting
Mantine's Text size prop sets both --text-fz and --text-lh; fz sets only the font size, so --text-lh falls back to var(--mantine-line-height) (1.55) instead of var(--mantine-line-height-xs) (1.4). At the default sm the header text line box grows 16.8px → 18.6px, which visibly raises the dashboard table tile's header row (HDXMultiSeriesTableChart.module.scss .tableHeader sets no height) — contradicting "nothing changes until you opt in". Keep size="xs" alongside fz="var(--hdx-content-font-size)" (the inline fz still wins for font-size) on both lines 39 and 51.
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
| return value in CONTENT_FONT_SIZES; | ||
| } | ||
|
|
||
| export const OPTIONS_CONTENT_FONT_SIZE = [ |
There was a problem hiding this comment.
🔵 minor — OPTIONS_CONTENT_FONT_SIZE re-enumerates the ContentFontSize union with no compile-time link
The union is now listed in three places (ContentFontSize, CONTENT_FONT_SIZES, OPTIONS_CONTENT_FONT_SIZE), and only the first two are tied together by Record<>. Adding a fourth size to CONTENT_FONT_SIZES compiles clean but never appears in the preferences Select. Derive the options from the record — e.g. a Record<ContentFontSize, string> label map mapped over Object.keys(CONTENT_FONT_SIZES) — so both stay exhaustive by construction.
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
| expect( | ||
| JSON.parse(window.localStorage.getItem(STORAGE_KEY) ?? '{}'), | ||
| ).toEqual(expect.objectContaining({ contentFontSize: 'lg' })); | ||
| }); |
There was a problem hiding this comment.
🔵 minor — The px-budget scaling — the part most likely to regress — has no test
The only new test covers the hook's resolved numbers; nothing exercises getResolvedColumnSize's scaled() defaults or the derived axis widths, so a future edit that drops contentFontScale from columnSizeOpts or reverts width={yAxisWidth} stays green. packages/app/src/components/__tests__/DBRowTable.test.tsx already has a "Column width persistence" harness asserting th inline widths — add a case there rendering with contentFontSize: 'lg' and asserting the timestamp column is 227px while a stored width stays untouched.
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
PR Review
5 finding(s): 🔴 0 critical · 🟠 0 major · 🔵 5 minor 2 posted as inline comment(s) on the changed lines. 3 listed below. Findings outside the changed lines3 minor
Severity is the reviewer's own estimate and is used for ordering, not filtering. No finding blocks merge automatically; a maintainer decides. |
| userPreferences: { contentFontSize }, | ||
| } = useUserPreferences(); | ||
|
|
||
| const size = contentFontSize ?? DEFAULT_CONTENT_FONT_SIZE; |
There was a problem hiding this comment.
Could this fall back to the default when the stored value isn't a known size?
Would reusing the type guard cover it?
const size =
contentFontSize && isContentFontSize(contentFontSize)
? contentFontSize
: DEFAULT_CONTENT_FONT_SIZE;There was a problem hiding this comment.
Good catch, and yes — fixed in 38e9883 with exactly the guard you suggested.
It was worse than a silent fallback: CONTENT_FONT_SIZES['xl'] is undefined, so the very next line destructuring { base, compact } off it threw a TypeError and took the whole app down. I confirmed that by reverting the guard with the new test in place:
✕ falls back to the default when the stored size is not one we ship
TypeError: Cannot destructure property 'base' of 'CONTENT_FONT_SIZES[size]' as it is undefined.
The test seeds localStorage with contentFontSize: 'xl' and asserts we land back on sm. I left a short comment on the guard noting why it isn't redundant against the declared type — the value is untrusted because it round-trips through localStorage, and migrateUserPreferences only validates colorMode, so anything else passes straight through.
… size Review feedback. The size comes from localStorage, so a hand-edited or stale blob can carry a value we do not ship; indexing CONTENT_FONT_SIZES with it returned undefined and the destructure threw. Reuse the isContentFontSize guard and pin it with a test. Co-authored-by: Mike Shi <mike@hyperdx.io>
Conflicts were all additive except the time chart's axis-width reasoning, which main refactored into AXIS_CHAR_BUDGET / axisLabelBudget. Took main's version there and moved the note about the gutter scaling with the content font size onto AXIS_CHAR_BUDGET, since that constant is the thing whose validity depends on it. Co-authored-by: Mike Shi <mike@hyperdx.io>
Duplicate code analysisNo new duplicate code introduced by this PR. jscpd compared this branch against |
| } | ||
| }, [effectiveFont]); | ||
|
|
||
| useEffect(() => { |
There was a problem hiding this comment.
🔵 minor — Users with a non-default size see a flash of small text and a column reflow on every load
userPreferencesAtom is an atomWithStorage with no getOnInit, and the vars are only written in a post-mount useEffect. So the first paint always uses 12px and scale: 1, then the text and the default column widths jump. SystemColorSchemeScript in useUserPreferences.tsx already solves this for color mode by reading hdx-user-preferences in an inline script before React runs. Have it set --hdx-content-font-size and --hdx-content-font-size-compact from contentFontSize too.
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
| border: 1px solid var(--color-border); | ||
| border-radius: 2px; | ||
| font-size: 11px; | ||
| font-size: var(--hdx-content-font-size-compact); |
There was a problem hiding this comment.
🔵 minor — Chart tooltip font now scales but its fixed 280px width does not
.chartTooltip keeps width: 280px. That is a character budget measured at 11px, the same kind of allocation the PR scales for the y-axis gutters and column widths. At lg (15px) about 27% fewer characters fit, so series names and values wrap or clip. Scale the width with the font, e.g. calc(280px * var(--hdx-content-font-size-compact) / 11px) is not valid CSS, so expose a unitless scale var or use em (about 25.5em).
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
| // Content density, overridden on <html> from the `contentFontSize` user | ||
| // preference. These defaults must match CONTENT_FONT_SIZES.sm so the | ||
| // pre-hydration render matches the default preference. | ||
| --hdx-content-font-size: 12px; |
There was a problem hiding this comment.
🔵 minor — The default content sizes are hardcoded twice: in app.scss and in CONTENT_FONT_SIZES.sm
The :root 12px/11px defaults have to match CONTENT_FONT_SIZES.sm (config/fonts.ts), and only a comment keeps them in sync. The unit test pins the TS values but not the SCSS. One fix: write a data-content-font-size attribute on <html> and define all three size pairs in SCSS keyed on it. Then the TS table only holds the numbers that recharts needs, and a test can check the two against each other.
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 columnId = opts.aliasMap?.[column] ? `"${column}"` : column; | ||
| const stored = opts.columnSizeStorage[columnId]; | ||
| if (stored != null) return stored; | ||
| const scaled = (px: number) => Math.round(px * opts.contentFontScale); |
There was a problem hiding this comment.
🔵 minor — No test for the column-width scaling, including the rule that dragged widths are never scaled
useContentFontSize.test.tsx covers only the hook. Add a DBRowTable.test.tsx case that sets contentFontSize: 'lg' and checks two things: default column widths (170/115/160) come out scaled, and a width stored in columnSizeStorage comes back unchanged. If someone later moves the stored != null early return below the scaling, the current tests would still pass.
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
Closes HDX-5430.
Why
Log table text is fixed at 12px. The only way to make it bigger today is browser zoom, which scales the nav, filter panel and dropdowns too — so the user loses even more of the vertical space they were trying to reclaim. Users want to scale the content without scaling the chrome.
What
One new user preference,
contentFontSize(sm|md|lg), surfaced as a Content font size select in the existing preferences modal under Appearance.The preference is written once, in
pages/_app.tsx, as two CSS custom properties on<html>:--hdx-content-font-size— body text (12 / 14 / 16px)--hdx-content-font-size-compact— secondary chart chrome (11 / 13 / 15px)Content surfaces read the vars instead of hardcoding px:
styles/LogTable.module.scss,components/DBTable/TableHeader.tsxHDXMultiSeriesTableChart.{tsx,module.scss}components/Table.module.scsscomponents/HyperJson.module.scssstyles/HDXLineChart.module.scss,styles/app.scssRecharts axes take a numeric
fontSizeprop rather than CSS, so those three charts (HDXMultiSeriesTimeChart,DBBarChart,DBHistogramChart) read the resolved number from auseContentFontSize()hook.smis the default and reproduces every size that was hardcoded before, so existing users see no change. The stored field is optional and the hook runs it through theisContentFontSizeguard, so a blob written before the field existed — or one carrying a size we no longer ship — falls back tosminstead of crashing.Out of scope, per the issue: chrome, navigation, headers, dropdowns, buttons and modal text.
Fixed px allocations that had to scale too
Several layout constants are really character budgets measured at the old 11/12px fonts, so they clip once the text grows. Each is now multiplied by the same
scaleratio the hook exposes, which keeps the budget constant at every setting:getResolvedColumnSize) — a width the user dragged to is left untouchedY_AXIS_WIDTHinHDXMultiSeriesTimeChart, and its three other consumers (singlePointBarSize, both annotationplotWidthcalculations). This is whatAXIS_CHAR_BUDGETdepends on, so that constant now documents the relationship.DBBarChart's y-axis width andBAR_LABEL_AXIS_HEIGHT(rotated x-labels need more vertical room)DBHistogramChart's y-axis widthNot done
DBHeatmapChartsizes its uPlot axes with a font shorthand string ('12px IBM Plex Mono, monospace') that uPlot measures imperatively, so it can't read a CSS var and doesn't fit the same pattern. Left at 12px rather than growing the diff.Making
DBBarChart's x-axis allocation responsive to measured height (raised by a reviewer for short dashboard tiles) is answered in-thread — it's a layout change that applies at every font size, so it belongs in its own PR.Testing
src/__tests__/useContentFontSize.test.tsx: default scale, fallback for preferences stored before the field existed, loading a saved non-default preference, fallback for an unrecognized stored size, and resolution + persistence of a change.make ci-lintandmake ci-unitclean on the merge commit (4526 app tests); E2E green on CI.main.Small (default, unchanged) vs large. The left nav, search bar, time picker and Run button are identical in both, while at large the histogram's y-axis gutter is wider (so the tick label still renders in full) and the timestamp column is wide enough for the complete timestamp:
Row side panel JSON at large:
The preferences modal after merging
main, with the new upstream "Row click" setting alongside this one:Linear Issue: HDX-5430