Skip to content

Commit bae04f3

Browse files
Merge branch 'main' into cursor/wrap-release-marker-tooltip-text-df62
2 parents c2e006d + 1773c11 commit bae04f3

18 files changed

Lines changed: 345 additions & 35 deletions
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
'@hyperdx/app': minor
3+
---
4+
5+
feat: add a content font size preference
6+
7+
Small text in the log/trace table was not adjustable without browser zoom, which
8+
also shrinks the surrounding chrome. User preferences now carry a **Content font
9+
size** setting (small / medium / large) that scales the search results table,
10+
data tables, expanded row JSON, and chart axes, legends, and tooltips. Small is
11+
the default and matches the previous sizes, so nothing changes until you opt in.

‎packages/app/pages/_app.tsx‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import { NextApiConfigResponseData } from '@/types';
3333
import { ConfirmProvider } from '@/useConfirm';
3434
import {
3535
SystemColorSchemeScript,
36+
useContentFontSize,
3637
useResolvedColorScheme,
3738
useUserPreferences,
3839
} from '@/useUserPreferences';
@@ -98,6 +99,8 @@ function AppContent({
9899
const { userPreferences } = useUserPreferences();
99100
const resolvedColorScheme = useResolvedColorScheme();
100101
const { themeName } = useAppTheme();
102+
const { base: contentFontSize, compact: compactContentFontSize } =
103+
useContentFontSize();
101104

102105
// ClickStack theme always uses Inter font - user preference is ignored
103106
// HyperDX theme allows user to select font preference
@@ -115,6 +118,21 @@ function AppContent({
115118
}
116119
}, [effectiveFont]);
117120

121+
useEffect(() => {
122+
// Single write point for the content font size preference; tables and
123+
// chart CSS read these vars (see styles/app.scss for the defaults).
124+
if (typeof document !== 'undefined') {
125+
document.documentElement.style.setProperty(
126+
'--hdx-content-font-size',
127+
`${contentFontSize}px`,
128+
);
129+
document.documentElement.style.setProperty(
130+
'--hdx-content-font-size-compact',
131+
`${compactContentFontSize}px`,
132+
);
133+
}
134+
}, [contentFontSize, compactContentFontSize]);
135+
118136
const getLayout = Component.getLayout ?? (page => page);
119137

120138
return (

‎packages/app/src/HDXMultiSeriesTableChart.module.scss‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
// .rowButtons pattern from LogTable.module.scss (lines 156-172),
55
// scoped down to a single icon. See HDX-4405.
66

7+
.tableWrapper {
8+
font-size: var(--hdx-content-font-size);
9+
}
10+
711
.tableHeader {
812
// Always-on 1px separator between the sticky header and the rows. An
913
// inset box-shadow rather than a border because the table sets

‎packages/app/src/HDXMultiSeriesTableChart.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ export const Table = ({
408408

409409
return (
410410
<div
411-
className={cx('overflow-auto h-100 fs-8', className)}
411+
className={cx('overflow-auto h-100', styles.tableWrapper, className)}
412412
ref={tableContainerRef}
413413
>
414414
<table

‎packages/app/src/HDXMultiSeriesTimeChart.tsx‎

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ import {
6969
toStartOfInterval,
7070
} from './ChartUtils';
7171
import { useFormatTime } from './useFormatTime';
72+
import { useContentFontSize } from './useUserPreferences';
7273

7374
import styles from '@styles/HDXLineChart.module.scss';
7475

@@ -777,7 +778,12 @@ export function collectMemoChartGradientHexes(
777778
// (NumberFormat.tsx), but 2 already distinguishes values >= 0.005 from 0.
778779
const MAX_AXIS_MANTISSA = 2;
779780

780-
/** Base width ceiling for a bare signed number - see MAX_AXIS_MANTISSA's comment. */
781+
/**
782+
* Base width ceiling for a bare signed number - see MAX_AXIS_MANTISSA's
783+
* comment. A character budget rather than a pixel one, which is why
784+
* Y_AXIS_WIDTH scales with the content font size preference: the gutter has to
785+
* grow with the tick font for this to keep holding at every setting.
786+
*/
781787
const AXIS_CHAR_BUDGET = 5;
782788

783789
// Flat, not suffix-length-scaled - IBM Plex Mono is monospace, so a longer
@@ -1351,6 +1357,12 @@ export const MemoChart = memo(function MemoChart({
13511357
const _id = useId();
13521358
const id = _id.replace(/:/g, '');
13531359

1360+
// The y-axis width budget is expressed in characters (see MAX_AXIS_MANTISSA),
1361+
// so it has to grow with the tick font or the widest labels clip.
1362+
const { compact: axisTickFontSize, scale: contentFontScale } =
1363+
useContentFontSize();
1364+
const yAxisWidth = Math.round(Y_AXIS_WIDTH * contentFontScale);
1365+
13541366
// recharts sync group, scoped via context (see chartSync).
13551367
const syncId = useChartSyncId();
13561368

@@ -1585,14 +1597,14 @@ export const MemoChart = memo(function MemoChart({
15851597
if (graphResults.length !== 1) return undefined;
15861598
const drawableWidth = Math.max(
15871599
0,
1588-
containerWidth - Y_AXIS_WIDTH - SINGLE_POINT_BAR_RIGHT_PADDING,
1600+
containerWidth - yAxisWidth - SINGLE_POINT_BAR_RIGHT_PADDING,
15891601
);
15901602
if (drawableWidth <= 0) return undefined;
15911603
return Math.max(
15921604
1,
15931605
Math.floor(drawableWidth * SINGLE_POINT_BAR_WIDTH_RATIO),
15941606
);
1595-
}, [displayType, graphResults.length, containerWidth]);
1607+
}, [displayType, graphResults.length, containerWidth, yAxisWidth]);
15961608

15971609
const formatTime = useFormatTime();
15981610
const xTickFormatter = useCallback(
@@ -1932,9 +1944,9 @@ export const MemoChart = memo(function MemoChart({
19321944
}
19331945
return layoutAnnotations(coloredAnnotations, {
19341946
domain: xAxisDomain,
1935-
plotWidth: Math.max(0, containerWidth - Y_AXIS_WIDTH),
1947+
plotWidth: Math.max(0, containerWidth - yAxisWidth),
19361948
});
1937-
}, [coloredAnnotations, xAxisDomain, containerWidth]);
1949+
}, [coloredAnnotations, xAxisDomain, containerWidth, yAxisWidth]);
19381950

19391951
const [hoveredAnnotation, setHoveredAnnotation] =
19401952
useState<HoveredAnnotation | null>(null);
@@ -1948,9 +1960,9 @@ export const MemoChart = memo(function MemoChart({
19481960
// Drawable width, so markers too close together share one label. Zero on
19491961
// the first paint (before ResponsiveContainer measures), which the
19501962
// renderer treats as "label everything".
1951-
plotWidth: Math.max(0, containerWidth - Y_AXIS_WIDTH),
1963+
plotWidth: Math.max(0, containerWidth - yAxisWidth),
19521964
});
1953-
}, [coloredAnnotations, xAxisDomain, containerWidth]);
1965+
}, [coloredAnnotations, xAxisDomain, containerWidth, yAxisWidth]);
19541966

19551967
return (
19561968
<div
@@ -2063,13 +2075,19 @@ export const MemoChart = memo(function MemoChart({
20632075
type="number"
20642076
tickFormatter={xTickFormatter}
20652077
minTickGap={100}
2066-
tick={{ fontSize: 11, fontFamily: 'IBM Plex Mono, monospace' }}
2078+
tick={{
2079+
fontSize: axisTickFontSize,
2080+
fontFamily: 'IBM Plex Mono, monospace',
2081+
}}
20672082
/>
20682083
<YAxis
2069-
width={Y_AXIS_WIDTH}
2084+
width={yAxisWidth}
20702085
minTickGap={25}
20712086
tickFormatter={yAxisTickFormatter}
2072-
tick={{ fontSize: 11, fontFamily: 'IBM Plex Mono, monospace' }}
2087+
tick={{
2088+
fontSize: axisTickFontSize,
2089+
fontFamily: 'IBM Plex Mono, monospace',
2090+
}}
20732091
domain={yAxisDomain}
20742092
ticks={yAxisTicks}
20752093
/>

‎packages/app/src/UserPreferencesModal.tsx‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,17 @@ import {
1313
} from '@mantine/core';
1414
import { IconFlask } from '@tabler/icons-react';
1515

16-
import { OPTIONS_FONTS } from './config/fonts';
16+
import {
17+
isContentFontSize,
18+
OPTIONS_CONTENT_FONT_SIZE,
19+
OPTIONS_FONTS,
20+
} from './config/fonts';
1721
import { useAppTheme } from './theme/ThemeProvider';
1822
import { isValidThemeName, themes } from './theme';
1923
import {
2024
DEFAULT_ROW_CLICK_ACTION,
2125
RowClickAction,
26+
useContentFontSize,
2227
UserPreferences,
2328
useUserPreferences,
2429
} from './useUserPreferences';
@@ -72,6 +77,7 @@ export const UserPreferencesModal = ({
7277
onClose: () => void;
7378
}) => {
7479
const { userPreferences, setUserPreference } = useUserPreferences();
80+
const { contentFontSize } = useContentFontSize();
7581
const { themeName, setTheme, isDev } = useAppTheme();
7682

7783
return (
@@ -168,6 +174,23 @@ export const UserPreferencesModal = ({
168174
/>
169175
</SettingContainer>
170176

177+
<SettingContainer
178+
label="Content font size"
179+
description="Text size for log tables, data tables, and charts"
180+
>
181+
<Select
182+
data-testid="content-font-size-select"
183+
value={contentFontSize}
184+
onChange={value =>
185+
value &&
186+
isContentFontSize(value) &&
187+
setUserPreference({ contentFontSize: value })
188+
}
189+
data={OPTIONS_CONTENT_FONT_SIZE}
190+
allowDeselect={false}
191+
/>
192+
</SettingContainer>
193+
171194
{/*
172195
Brand Theme Selector - DEV MODE ONLY
173196
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
import { Provider } from 'jotai';
2+
import { act, renderHook } from '@testing-library/react';
3+
4+
import { CONTENT_FONT_SIZES } from '@/config/fonts';
5+
import { useContentFontSize, useUserPreferences } from '@/useUserPreferences';
6+
7+
const STORAGE_KEY = 'hdx-user-preferences';
8+
9+
const renderContentFontSize = () =>
10+
renderHook(
11+
() => ({
12+
resolved: useContentFontSize(),
13+
preferences: useUserPreferences(),
14+
}),
15+
{ wrapper: Provider },
16+
);
17+
18+
describe('useContentFontSize', () => {
19+
beforeEach(() => {
20+
window.localStorage.clear();
21+
});
22+
23+
// The `sm` scale is what every content surface had hardcoded before the
24+
// preference existed, so it has to stay the default.
25+
it('defaults to the small scale', () => {
26+
const { result } = renderContentFontSize();
27+
28+
expect(CONTENT_FONT_SIZES.sm).toEqual({ base: 12, compact: 11 });
29+
expect(result.current.resolved).toEqual({
30+
contentFontSize: 'sm',
31+
...CONTENT_FONT_SIZES.sm,
32+
scale: 1,
33+
});
34+
});
35+
36+
it('falls back to the default for preferences stored before the setting existed', () => {
37+
window.localStorage.setItem(
38+
STORAGE_KEY,
39+
JSON.stringify({
40+
isUTC: true,
41+
timeFormat: '24h',
42+
colorMode: 'dark',
43+
font: 'Inter',
44+
}),
45+
);
46+
47+
const { result } = renderContentFontSize();
48+
49+
expect(result.current.resolved.contentFontSize).toBe('sm');
50+
});
51+
52+
it('loads a non-default preference saved in a previous session', () => {
53+
window.localStorage.setItem(
54+
STORAGE_KEY,
55+
JSON.stringify({
56+
isUTC: false,
57+
timeFormat: '12h',
58+
colorMode: 'dark',
59+
font: 'IBM Plex Mono',
60+
contentFontSize: 'md',
61+
}),
62+
);
63+
64+
const { result } = renderContentFontSize();
65+
66+
expect(result.current.resolved).toEqual({
67+
contentFontSize: 'md',
68+
...CONTENT_FONT_SIZES.md,
69+
scale: CONTENT_FONT_SIZES.md.base / CONTENT_FONT_SIZES.sm.base,
70+
});
71+
});
72+
73+
it('falls back to the default when the stored size is not one we ship', () => {
74+
window.localStorage.setItem(
75+
STORAGE_KEY,
76+
JSON.stringify({
77+
isUTC: false,
78+
timeFormat: '12h',
79+
colorMode: 'dark',
80+
font: 'IBM Plex Mono',
81+
contentFontSize: 'xl',
82+
}),
83+
);
84+
85+
const { result } = renderContentFontSize();
86+
87+
expect(result.current.resolved).toEqual({
88+
contentFontSize: 'sm',
89+
...CONTENT_FONT_SIZES.sm,
90+
scale: 1,
91+
});
92+
});
93+
94+
it('resolves the stored preference', () => {
95+
const { result } = renderContentFontSize();
96+
97+
act(() =>
98+
result.current.preferences.setUserPreference({ contentFontSize: 'lg' }),
99+
);
100+
101+
expect(result.current.resolved).toEqual({
102+
contentFontSize: 'lg',
103+
...CONTENT_FONT_SIZES.lg,
104+
scale: CONTENT_FONT_SIZES.lg.base / CONTENT_FONT_SIZES.sm.base,
105+
});
106+
expect(
107+
JSON.parse(window.localStorage.getItem(STORAGE_KEY) ?? '{}'),
108+
).toEqual(expect.objectContaining({ contentFontSize: 'lg' }));
109+
});
110+
});

‎packages/app/src/components/DBBarChart.tsx‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
import { Flex } from '@mantine/core';
1313

1414
import type { NumberFormat } from '@/types';
15+
import { useContentFontSize } from '@/useUserPreferences';
1516
import { formatNumber } from '@/utils';
1617

1718
import {
@@ -24,6 +25,7 @@ import { ChartTooltipContainer, ChartTooltipItem } from './charts/ChartTooltip';
2425

2526
const MAX_BAR_LABEL_LENGTH = 14;
2627
const BAR_LABEL_AXIS_HEIGHT = 80; // increased height to accommodate rotated + truncated labels
28+
const Y_AXIS_WIDTH = 40;
2729

2830
const truncateBarLabel = (value: string) =>
2931
value.length > MAX_BAR_LABEL_LENGTH
@@ -71,6 +73,14 @@ export const DBBarChart = (props: CategoricalChartProps) => {
7173
chartData,
7274
responseFormatError,
7375
} = useCategoricalChart(props);
76+
// Both axis allocations are character budgets at the default tick font, so
77+
// they scale with it rather than clipping the labels.
78+
const { base: axisTickFontSize, scale: contentFontScale } =
79+
useContentFontSize();
80+
const barLabelAxisHeight = Math.round(
81+
BAR_LABEL_AXIS_HEIGHT * contentFontScale,
82+
);
83+
const yAxisWidth = Math.round(Y_AXIS_WIDTH * contentFontScale);
7484

7585
return (
7686
<ChartContainer title={props.title} toolbarItems={toolbarItems}>
@@ -113,12 +123,15 @@ export const DBBarChart = (props: CategoricalChartProps) => {
113123
interval={0}
114124
angle={-45}
115125
textAnchor="end"
116-
height={BAR_LABEL_AXIS_HEIGHT}
126+
height={barLabelAxisHeight}
117127
tickFormatter={truncateBarLabel}
118-
tick={{ fontSize: 12, fontFamily: 'IBM Plex Mono, monospace' }}
128+
tick={{
129+
fontSize: axisTickFontSize,
130+
fontFamily: 'IBM Plex Mono, monospace',
131+
}}
119132
/>
120133
<YAxis
121-
width={40}
134+
width={yAxisWidth}
122135
minTickGap={25}
123136
tickFormatter={(value: number) =>
124137
resolvedNumberFormat
@@ -128,7 +141,10 @@ export const DBBarChart = (props: CategoricalChartProps) => {
128141
compactDisplay: 'short',
129142
}).format(value)
130143
}
131-
tick={{ fontSize: 12, fontFamily: 'IBM Plex Mono, monospace' }}
144+
tick={{
145+
fontSize: axisTickFontSize,
146+
fontFamily: 'IBM Plex Mono, monospace',
147+
}}
132148
/>
133149
<Bar dataKey="value">
134150
{chartData.map(entry => (

0 commit comments

Comments
 (0)