From 29e3d758020d10eb83fa0a043154cc25e45b1200 Mon Sep 17 00:00:00 2001 From: Jordan Simonovski Date: Fri, 13 Nov 2026 15:39:18 +1100 Subject: [PATCH 1/5] feat(app): hidden CRT mode, unlocked by the Konami code in preferences --- .changeset/crt-mode-easter-egg.md | 5 + packages/app/pages/_app.tsx | 4 + packages/app/src/UserPreferencesModal.tsx | 39 +++- .../__tests__/UserPreferencesModal.test.tsx | 46 +++++ .../app/src/components/CrtOverlay.module.scss | 97 +++++++++ packages/app/src/components/CrtOverlay.tsx | 18 ++ .../components/CrtUnlockReveal.module.scss | 186 ++++++++++++++++++ .../app/src/components/CrtUnlockReveal.tsx | 74 +++++++ .../src/hooks/__tests__/useKonamiCode.test.ts | 53 +++++ packages/app/src/hooks/useKonamiCode.ts | 31 +++ packages/app/src/useUserPreferences.tsx | 2 + 11 files changed, 554 insertions(+), 1 deletion(-) create mode 100644 .changeset/crt-mode-easter-egg.md create mode 100644 packages/app/src/components/CrtOverlay.module.scss create mode 100644 packages/app/src/components/CrtOverlay.tsx create mode 100644 packages/app/src/components/CrtUnlockReveal.module.scss create mode 100644 packages/app/src/components/CrtUnlockReveal.tsx create mode 100644 packages/app/src/hooks/__tests__/useKonamiCode.test.ts create mode 100644 packages/app/src/hooks/useKonamiCode.ts diff --git a/.changeset/crt-mode-easter-egg.md b/.changeset/crt-mode-easter-egg.md new file mode 100644 index 000000000..d35fa9b2f --- /dev/null +++ b/.changeset/crt-mode-easter-egg.md @@ -0,0 +1,5 @@ +--- +'@hyperdx/app': patch +--- + +feat: hidden CRT mode in user preferences, revealed by typing the Konami code in the preferences modal diff --git a/packages/app/pages/_app.tsx b/packages/app/pages/_app.tsx index 54c437f8b..838b6089d 100644 --- a/packages/app/pages/_app.tsx +++ b/packages/app/pages/_app.tsx @@ -13,6 +13,7 @@ import { import { ReactQueryDevtools } from '@tanstack/react-query-devtools'; import { usePageTitle } from '@/brand'; +import { CrtOverlay } from '@/components/CrtOverlay'; import { MANTINE_FONT_MAP } from '@/config/fonts'; import { ibmPlexMono, inter, roboto, robotoMono } from '@/fonts'; import { fetchServerVersion, installHdxDebug } from '@/hdxDebug'; @@ -22,6 +23,7 @@ import { SystemColorSchemeScript, useContentFontSize, useResolvedColorScheme, + useUserPreferences, } from '@/useUserPreferences'; import '@mantine/core/styles.css'; @@ -79,6 +81,7 @@ function AppContent({ pageProps: AppProps['pageProps']; }) { const resolvedColorScheme = useResolvedColorScheme(); + const { userPreferences } = useUserPreferences(); const { base: contentFontSize, compact: compactContentFontSize } = useContentFontSize(); @@ -107,6 +110,7 @@ function AppContent({ {getLayout()} + {userPreferences.crtMode && } ); } diff --git a/packages/app/src/UserPreferencesModal.tsx b/packages/app/src/UserPreferencesModal.tsx index 6bc00950d..c814d336b 100644 --- a/packages/app/src/UserPreferencesModal.tsx +++ b/packages/app/src/UserPreferencesModal.tsx @@ -1,9 +1,19 @@ import * as React from 'react'; import { Badge } from '@clickhouse/click-ui'; -import { Divider, Group, Modal, Select, Stack, Text } from '@mantine/core'; +import { + Divider, + Group, + Modal, + Select, + Stack, + Switch, + Text, +} from '@mantine/core'; +import { CrtUnlockReveal } from './components/CrtUnlockReveal'; import { TimeZoneSelect, TimeZoneShortcuts } from './components/TimeZoneSelect'; import { isContentFontSize, OPTIONS_CONTENT_FONT_SIZE } from './config/fonts'; +import { useKonamiCode } from './hooks/useKonamiCode'; import { DEFAULT_ROW_CLICK_ACTION, RowClickAction, @@ -56,6 +66,27 @@ export const UserPreferencesModal = ({ }) => { const { userPreferences, setUserPreference } = useUserPreferences(); const { contentFontSize } = useContentFontSize(); + const [crtUnlocked, setCrtUnlocked] = React.useState(false); + // AppNav keeps this component mounted while closed, so gate on `opened`. + useKonamiCode( + React.useCallback(() => opened && setCrtUnlocked(true), [opened]), + ); + React.useEffect(() => { + if (!opened) setCrtUnlocked(false); + }, [opened]); + + const crtSetting = ( + + setUserPreference({ crtMode: e.currentTarget.checked })} + /> + + ); return ( + + {crtUnlocked ? ( + {crtSetting} + ) : ( + userPreferences.crtMode && crtSetting + )} ); diff --git a/packages/app/src/__tests__/UserPreferencesModal.test.tsx b/packages/app/src/__tests__/UserPreferencesModal.test.tsx index ddd9213b7..62d8bb9aa 100644 --- a/packages/app/src/__tests__/UserPreferencesModal.test.tsx +++ b/packages/app/src/__tests__/UserPreferencesModal.test.tsx @@ -1,3 +1,4 @@ +import * as React from 'react'; import { Provider } from 'jotai'; import { screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; @@ -99,4 +100,49 @@ describe('UserPreferencesModal', () => { expect(readStoredPreferences().rowClickAction).toBe('expand'); }); }); + + describe('CRT mode', () => { + const KONAMI = + '{ArrowUp}{ArrowUp}{ArrowDown}{ArrowDown}{ArrowLeft}{ArrowRight}{ArrowLeft}{ArrowRight}ba'; + + it('hides the toggle until the Konami code is typed', async () => { + renderModal(); + expect(screen.queryByTestId('crt-mode-switch')).toBeNull(); + + await userEvent.keyboard(KONAMI); + expect(screen.getByTestId('crt-unlock-scene')).toBeInTheDocument(); + await userEvent.click(screen.getByTestId('crt-mode-switch')); + + expect(readStoredPreferences().crtMode).toBe(true); + }); + + it('ignores the Konami code while the modal is closed', async () => { + window.localStorage.clear(); + const ClosedThenOpened = () => { + const [opened, setOpened] = React.useState(false); + return ( + <> + + {}} /> + + ); + }; + renderWithMantine( + + + , + ); + await userEvent.keyboard(KONAMI); + await userEvent.click(screen.getByText('open')); + await screen.findByTestId('time-zone-select'); + + expect(screen.queryByTestId('crt-mode-switch')).toBeNull(); + }); + + it('shows the toggle while CRT mode is on so it can be turned off', () => { + renderModal({ crtMode: true }); + + expect(screen.getByTestId('crt-mode-switch')).toBeChecked(); + }); + }); }); diff --git a/packages/app/src/components/CrtOverlay.module.scss b/packages/app/src/components/CrtOverlay.module.scss new file mode 100644 index 000000000..c8bd319ff --- /dev/null +++ b/packages/app/src/components/CrtOverlay.module.scss @@ -0,0 +1,97 @@ +// Above modals and notifications; it never takes pointer events. +.overlay { + position: fixed; + inset: 0; + z-index: 2147483647; + pointer-events: none; + // Rounded screen corners plus edge shading read as a curved tube. + border-radius: 3vmin / 4vmin; + box-shadow: + 0 0 0 10vmin #000, + inset 0 0 10vmin rgba(0, 0, 0, 0.55); + background: radial-gradient( + ellipse at center, + rgba(255, 255, 255, 0.03) 0%, + transparent 55%, + rgba(0, 0, 0, 0.35) 100% + ); + + &::before, + &::after { + content: ''; + position: absolute; + inset: 0; + } + + // The light half keeps the lines visible on the dark theme. + &::before { + background: repeating-linear-gradient( + to bottom, + rgba(0, 0, 0, 0.3) 0, + rgba(0, 0, 0, 0.3) 2px, + rgba(255, 255, 255, 0.03) 2px, + rgba(255, 255, 255, 0.03) 4px + ); + } + + // RGB phosphor mask; this layer also carries the flicker. + &::after { + background: repeating-linear-gradient( + to right, + rgba(255, 0, 0, 0.05) 0, + rgba(255, 0, 0, 0.05) 1px, + rgba(0, 255, 0, 0.04) 1px, + rgba(0, 255, 0, 0.04) 2px, + rgba(0, 0, 255, 0.05) 2px, + rgba(0, 0, 255, 0.05) 3px + ); + will-change: opacity; + animation: flicker 0.15s steps(1) infinite; + + @media (prefers-reduced-motion: reduce) { + animation: none; + } + } +} + +.roll { + position: absolute; + inset: 0 0 auto; + height: 15vh; + background: linear-gradient( + to bottom, + transparent, + rgba(255, 255, 255, 0.07), + transparent + ); + transform: translateY(-15vh); + will-change: transform; + animation: roll 8s linear infinite; + + @media (prefers-reduced-motion: reduce) { + display: none; + } +} + +@keyframes roll { + to { + transform: translateY(100vh); + } +} + +@keyframes flicker { + 0% { + opacity: 0.7; + } + 50% { + opacity: 1; + } +} + +// Chromatic aberration and phosphor glow on all text. +:global(html[data-crt]) body { + text-shadow: + 0.6px 0 rgba(255, 0, 80, 0.35), + -0.6px 0 rgba(0, 200, 255, 0.35), + 0 0 2px color-mix(in srgb, currentColor 60%, transparent); +} diff --git a/packages/app/src/components/CrtOverlay.tsx b/packages/app/src/components/CrtOverlay.tsx new file mode 100644 index 000000000..89d26635c --- /dev/null +++ b/packages/app/src/components/CrtOverlay.tsx @@ -0,0 +1,18 @@ +import { useEffect } from 'react'; + +import styles from './CrtOverlay.module.scss'; + +/** Full-viewport CRT effect. Mount only while the preference is on. */ +export function CrtOverlay() { + useEffect(() => { + // Lets the global text glow in the stylesheet apply without a body class. + document.documentElement.setAttribute('data-crt', ''); + return () => document.documentElement.removeAttribute('data-crt'); + }, []); + + return ( +
+
+
+ ); +} diff --git a/packages/app/src/components/CrtUnlockReveal.module.scss b/packages/app/src/components/CrtUnlockReveal.module.scss new file mode 100644 index 000000000..7ab071e7b --- /dev/null +++ b/packages/app/src/components/CrtUnlockReveal.module.scss @@ -0,0 +1,186 @@ +$phosphor: #33ff66; +// When the scene collapses; the setting powers on as it finishes. +$collapse-at: 3.1s; + +// Scene and content share one grid cell so the scene sits on top of the setting. +.root { + display: grid; + + > * { + grid-area: 1 / 1; + } +} + +.content { + align-self: center; + animation: power-on 0.5s ($collapse-at + 0.3s) both ease-out; +} + +.flash { + position: fixed; + inset: 0; + z-index: 2147483646; + pointer-events: none; + background: #fff; + opacity: 0; + animation: flash 0.6s ease-out; +} + +.scene { + position: relative; + z-index: 1; + overflow: hidden; + padding: 0.75rem 1rem; + border-radius: 6px; + background: #000; + color: $phosphor; + font-family: var(--mantine-font-family-monospace); + font-size: 0.85rem; + line-height: 1.6; + text-shadow: 0 0 6px rgba($phosphor, 0.8); + box-shadow: inset 0 0 2rem rgba($phosphor, 0.25); + animation: + shake 0.4s 0.05s, + collapse 0.35s $collapse-at forwards ease-in; + + &::after { + content: ''; + position: absolute; + inset: 0; + pointer-events: none; + background: repeating-linear-gradient( + to bottom, + rgba(0, 0, 0, 0.35) 0, + rgba(0, 0, 0, 0.35) 1px, + transparent 1px, + transparent 3px + ); + } +} + +// Width counts the "> " prompt as two extra characters. +.line { + display: inline-block; + width: 0; + overflow: hidden; + white-space: nowrap; + vertical-align: bottom; + animation: type 0.5s var(--delay) steps(calc(var(--chars) + 2)) forwards; +} + +.cursor::after { + content: '_'; + animation: blink 0.5s steps(1) infinite; +} + +.bar { + width: 22ch; + height: 0.9rem; + margin: 0.3rem 0; + border: 1px solid currentColor; + box-shadow: 0 0 6px rgba($phosphor, 0.6); +} + +.barFill { + width: 0; + height: 100%; + background: repeating-linear-gradient( + to right, + currentColor 0, + currentColor 0.8ch, + transparent 0.8ch, + transparent 1ch + ); + animation: fill 1.1s 1.3s steps(22) forwards; +} + +@media (prefers-reduced-motion: reduce) { + .scene, + .flash { + display: none; + } + + .content { + animation: none; + } +} + +@keyframes flash { + 0% { + opacity: 0.85; + } + 100% { + opacity: 0; + } +} + +@keyframes shake { + 0%, + 100% { + transform: translate(0, 0); + } + 20% { + transform: translate(-6px, 2px); + } + 40% { + transform: translate(5px, -3px); + } + 60% { + transform: translate(-4px, 1px); + } + 80% { + transform: translate(3px, -1px); + } +} + +@keyframes type { + to { + width: calc((var(--chars) + 2) * 1ch); + } +} + +@keyframes fill { + to { + width: 100%; + } +} + +@keyframes blink { + 50% { + opacity: 0; + } +} + +// A CRT switching off: squash to a bright line, then to a dot. +@keyframes collapse { + 0% { + transform: none; + filter: none; + } + 60% { + transform: scale(1, 0.02); + filter: brightness(3); + } + 100% { + transform: scale(0, 0.02); + filter: brightness(5); + } +} + +@keyframes power-on { + 0% { + opacity: 0; + transform: scale(0, 0.02); + filter: brightness(4); + } + 40% { + opacity: 1; + transform: scale(1, 0.02); + filter: brightness(3); + } + 100% { + opacity: 1; + transform: none; + filter: none; + } +} diff --git a/packages/app/src/components/CrtUnlockReveal.tsx b/packages/app/src/components/CrtUnlockReveal.tsx new file mode 100644 index 000000000..c7ace0104 --- /dev/null +++ b/packages/app/src/components/CrtUnlockReveal.tsx @@ -0,0 +1,74 @@ +import * as React from 'react'; + +import styles from './CrtUnlockReveal.module.scss'; + +const LINES = [ + { text: 'Cheat code accepted', delay: 0.3 }, + { text: 'Loading crt_mode.sys', delay: 0.8 }, + { text: 'Warming up the tube...', delay: 2.4 }, +]; + +/** Plays a retro boot scene over `children`, then powers them on underneath. */ +export function CrtUnlockReveal({ children }: { children: React.ReactNode }) { + const [playing, setPlaying] = React.useState(true); + + return ( +
+
{children}
+ {playing && ( + <> +
+
{ + // Child animations bubble up here; only the final collapse ends the scene. + if ( + e.target === e.currentTarget && + e.animationName.includes('collapse') + ) { + setPlaying(false); + } + }} + > + {LINES.slice(0, 2).map(line => ( + + ))} +
+
+
+ +
+ + )} +
+ ); +} + +function Line({ + text, + delay, + cursor, +}: { + text: string; + delay: number; + cursor?: boolean; +}) { + return ( +
+ + {'> '} + {text} + +
+ ); +} diff --git a/packages/app/src/hooks/__tests__/useKonamiCode.test.ts b/packages/app/src/hooks/__tests__/useKonamiCode.test.ts new file mode 100644 index 000000000..46f2362e7 --- /dev/null +++ b/packages/app/src/hooks/__tests__/useKonamiCode.test.ts @@ -0,0 +1,53 @@ +import { act, renderHook } from '@testing-library/react'; + +import { useKonamiCode } from '@/hooks/useKonamiCode'; + +const CODE = [ + 'ArrowUp', + 'ArrowUp', + 'ArrowDown', + 'ArrowDown', + 'ArrowLeft', + 'ArrowRight', + 'ArrowLeft', + 'ArrowRight', + 'b', + 'a', +]; + +const press = (keys: string[]) => + act(() => { + keys.forEach(key => + window.dispatchEvent(new KeyboardEvent('keydown', { key })), + ); + }); + +describe('useKonamiCode', () => { + it('fires once per full sequence', () => { + const onMatch = jest.fn(); + renderHook(() => useKonamiCode(onMatch)); + + press(CODE.slice(0, -1)); + expect(onMatch).not.toHaveBeenCalled(); + + press(['a']); + expect(onMatch).toHaveBeenCalledTimes(1); + }); + + it('matches after stray keys and with caps lock on', () => { + const onMatch = jest.fn(); + renderHook(() => useKonamiCode(onMatch)); + + press(['ArrowUp', 'x', 'ArrowUp', ...CODE.slice(0, -2), 'B', 'A']); + expect(onMatch).toHaveBeenCalledTimes(1); + }); + + it('stops listening on unmount', () => { + const onMatch = jest.fn(); + const { unmount } = renderHook(() => useKonamiCode(onMatch)); + + unmount(); + press(CODE); + expect(onMatch).not.toHaveBeenCalled(); + }); +}); diff --git a/packages/app/src/hooks/useKonamiCode.ts b/packages/app/src/hooks/useKonamiCode.ts new file mode 100644 index 000000000..3e75b677e --- /dev/null +++ b/packages/app/src/hooks/useKonamiCode.ts @@ -0,0 +1,31 @@ +import { useEffect } from 'react'; + +const KONAMI_CODE = [ + 'ArrowUp', + 'ArrowUp', + 'ArrowDown', + 'ArrowDown', + 'ArrowLeft', + 'ArrowRight', + 'ArrowLeft', + 'ArrowRight', + 'b', + 'a', +].join(); + +/** Calls `onMatch` each time the Konami code is typed. Pass a stable callback. */ +export function useKonamiCode(onMatch: () => void) { + useEffect(() => { + const recent: string[] = []; + const onKeyDown = (e: KeyboardEvent) => { + recent.push(e.key.length === 1 ? e.key.toLowerCase() : e.key); + if (recent.length > 10) recent.shift(); + if (recent.join() === KONAMI_CODE) { + recent.length = 0; + onMatch(); + } + }; + window.addEventListener('keydown', onKeyDown); + return () => window.removeEventListener('keydown', onKeyDown); + }, [onMatch]); +} diff --git a/packages/app/src/useUserPreferences.tsx b/packages/app/src/useUserPreferences.tsx index fec956733..d2961da14 100644 --- a/packages/app/src/useUserPreferences.tsx +++ b/packages/app/src/useUserPreferences.tsx @@ -45,6 +45,8 @@ export type UserPreferences = { * fall back to `DEFAULT_ROW_CLICK_ACTION`. */ rowClickAction?: RowClickAction; + /** CRT screen effect. The toggle stays hidden until the Konami code is typed. */ + crtMode?: boolean; }; // Legacy type for migration From a73bb75dadb4016b411e8a2cde989620dc63781e Mon Sep 17 00:00:00 2001 From: Jordan Simonovski Date: Wed, 18 Nov 2026 14:22:18 +1100 Subject: [PATCH 2/5] fix(app): pass style lint in the CRT stylesheets, ignore keydown events with no key --- .../app/src/components/CrtOverlay.module.scss | 37 ++++++++++--------- .../components/CrtUnlockReveal.module.scss | 22 ++++++++--- .../src/hooks/__tests__/useKonamiCode.test.ts | 12 ++++++ packages/app/src/hooks/useKonamiCode.ts | 2 + 4 files changed, 50 insertions(+), 23 deletions(-) diff --git a/packages/app/src/components/CrtOverlay.module.scss b/packages/app/src/components/CrtOverlay.module.scss index c8bd319ff..b0525eccd 100644 --- a/packages/app/src/components/CrtOverlay.module.scss +++ b/packages/app/src/components/CrtOverlay.module.scss @@ -4,16 +4,17 @@ inset: 0; z-index: 2147483647; pointer-events: none; + // Rounded screen corners plus edge shading read as a curved tube. border-radius: 3vmin / 4vmin; box-shadow: 0 0 0 10vmin #000, - inset 0 0 10vmin rgba(0, 0, 0, 0.55); + inset 0 0 10vmin rgb(0 0 0 / 55%); background: radial-gradient( ellipse at center, - rgba(255, 255, 255, 0.03) 0%, + rgb(255 255 255 / 3%) 0%, transparent 55%, - rgba(0, 0, 0, 0.35) 100% + rgb(0 0 0 / 35%) 100% ); &::before, @@ -27,10 +28,10 @@ &::before { background: repeating-linear-gradient( to bottom, - rgba(0, 0, 0, 0.3) 0, - rgba(0, 0, 0, 0.3) 2px, - rgba(255, 255, 255, 0.03) 2px, - rgba(255, 255, 255, 0.03) 4px + rgb(0 0 0 / 30%) 0, + rgb(0 0 0 / 30%) 2px, + rgb(255 255 255 / 3%) 2px, + rgb(255 255 255 / 3%) 4px ); } @@ -38,12 +39,12 @@ &::after { background: repeating-linear-gradient( to right, - rgba(255, 0, 0, 0.05) 0, - rgba(255, 0, 0, 0.05) 1px, - rgba(0, 255, 0, 0.04) 1px, - rgba(0, 255, 0, 0.04) 2px, - rgba(0, 0, 255, 0.05) 2px, - rgba(0, 0, 255, 0.05) 3px + rgb(255 0 0 / 5%) 0, + rgb(255 0 0 / 5%) 1px, + rgb(0 255 0 / 4%) 1px, + rgb(0 255 0 / 4%) 2px, + rgb(0 0 255 / 5%) 2px, + rgb(0 0 255 / 5%) 3px ); will-change: opacity; animation: flicker 0.15s steps(1) infinite; @@ -61,7 +62,7 @@ background: linear-gradient( to bottom, transparent, - rgba(255, 255, 255, 0.07), + rgb(255 255 255 / 7%), transparent ); transform: translateY(-15vh); @@ -83,15 +84,17 @@ 0% { opacity: 0.7; } + 50% { opacity: 1; } } // Chromatic aberration and phosphor glow on all text. +/* stylelint-disable-next-line selector-pseudo-class-no-unknown */ :global(html[data-crt]) body { text-shadow: - 0.6px 0 rgba(255, 0, 80, 0.35), - -0.6px 0 rgba(0, 200, 255, 0.35), - 0 0 2px color-mix(in srgb, currentColor 60%, transparent); + 0.6px 0 rgb(255 0 80 / 35%), + -0.6px 0 rgb(0 200 255 / 35%), + 0 0 2px color-mix(in srgb, currentcolor 60%, transparent); } diff --git a/packages/app/src/components/CrtUnlockReveal.module.scss b/packages/app/src/components/CrtUnlockReveal.module.scss index 7ab071e7b..2f446a71b 100644 --- a/packages/app/src/components/CrtUnlockReveal.module.scss +++ b/packages/app/src/components/CrtUnlockReveal.module.scss @@ -1,4 +1,5 @@ -$phosphor: #33ff66; +$phosphor: #3f6; + // When the scene collapses; the setting powers on as it finishes. $collapse-at: 3.1s; @@ -50,8 +51,8 @@ $collapse-at: 3.1s; pointer-events: none; background: repeating-linear-gradient( to bottom, - rgba(0, 0, 0, 0.35) 0, - rgba(0, 0, 0, 0.35) 1px, + rgb(0 0 0 / 35%) 0, + rgb(0 0 0 / 35%) 1px, transparent 1px, transparent 3px ); @@ -77,7 +78,7 @@ $collapse-at: 3.1s; width: 22ch; height: 0.9rem; margin: 0.3rem 0; - border: 1px solid currentColor; + border: 1px solid currentcolor; box-shadow: 0 0 6px rgba($phosphor, 0.6); } @@ -86,8 +87,8 @@ $collapse-at: 3.1s; height: 100%; background: repeating-linear-gradient( to right, - currentColor 0, - currentColor 0.8ch, + currentcolor 0, + currentcolor 0.8ch, transparent 0.8ch, transparent 1ch ); @@ -109,6 +110,7 @@ $collapse-at: 3.1s; 0% { opacity: 0.85; } + 100% { opacity: 0; } @@ -119,15 +121,19 @@ $collapse-at: 3.1s; 100% { transform: translate(0, 0); } + 20% { transform: translate(-6px, 2px); } + 40% { transform: translate(5px, -3px); } + 60% { transform: translate(-4px, 1px); } + 80% { transform: translate(3px, -1px); } @@ -157,10 +163,12 @@ $collapse-at: 3.1s; transform: none; filter: none; } + 60% { transform: scale(1, 0.02); filter: brightness(3); } + 100% { transform: scale(0, 0.02); filter: brightness(5); @@ -173,11 +181,13 @@ $collapse-at: 3.1s; transform: scale(0, 0.02); filter: brightness(4); } + 40% { opacity: 1; transform: scale(1, 0.02); filter: brightness(3); } + 100% { opacity: 1; transform: none; diff --git a/packages/app/src/hooks/__tests__/useKonamiCode.test.ts b/packages/app/src/hooks/__tests__/useKonamiCode.test.ts index 46f2362e7..8ea6f3a53 100644 --- a/packages/app/src/hooks/__tests__/useKonamiCode.test.ts +++ b/packages/app/src/hooks/__tests__/useKonamiCode.test.ts @@ -42,6 +42,18 @@ describe('useKonamiCode', () => { expect(onMatch).toHaveBeenCalledTimes(1); }); + it('ignores keydown events with no key', () => { + const onError = jest.fn(); + window.addEventListener('error', onError); + renderHook(() => useKonamiCode(jest.fn())); + + act(() => { + window.dispatchEvent(new Event('keydown')); + }); + window.removeEventListener('error', onError); + expect(onError).not.toHaveBeenCalled(); + }); + it('stops listening on unmount', () => { const onMatch = jest.fn(); const { unmount } = renderHook(() => useKonamiCode(onMatch)); diff --git a/packages/app/src/hooks/useKonamiCode.ts b/packages/app/src/hooks/useKonamiCode.ts index 3e75b677e..8d135b5b4 100644 --- a/packages/app/src/hooks/useKonamiCode.ts +++ b/packages/app/src/hooks/useKonamiCode.ts @@ -18,6 +18,8 @@ export function useKonamiCode(onMatch: () => void) { useEffect(() => { const recent: string[] = []; const onKeyDown = (e: KeyboardEvent) => { + // Browser autofill dispatches keydown events with no `key`. + if (!e.key) return; recent.push(e.key.length === 1 ? e.key.toLowerCase() : e.key); if (recent.length > 10) recent.shift(); if (recent.join() === KONAMI_CODE) { From 405ce5594d11179974eb7e61ce7b1b80e812c88d Mon Sep 17 00:00:00 2001 From: Jordan Simonovski Date: Wed, 18 Nov 2026 14:24:11 +1100 Subject: [PATCH 3/5] chore: keep the easter egg out of the changeset --- .changeset/crt-mode-easter-egg.md | 5 ----- .changeset/user-preferences-addition.md | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) delete mode 100644 .changeset/crt-mode-easter-egg.md create mode 100644 .changeset/user-preferences-addition.md diff --git a/.changeset/crt-mode-easter-egg.md b/.changeset/crt-mode-easter-egg.md deleted file mode 100644 index d35fa9b2f..000000000 --- a/.changeset/crt-mode-easter-egg.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@hyperdx/app': patch ---- - -feat: hidden CRT mode in user preferences, revealed by typing the Konami code in the preferences modal diff --git a/.changeset/user-preferences-addition.md b/.changeset/user-preferences-addition.md new file mode 100644 index 000000000..0711891c7 --- /dev/null +++ b/.changeset/user-preferences-addition.md @@ -0,0 +1,5 @@ +--- +'@hyperdx/app': patch +--- + +feat: small addition to user preferences From 2a9a134f60eee253ad8d4a09759c9e78f35733cb Mon Sep 17 00:00:00 2001 From: Jordan Simonovski Date: Wed, 18 Nov 2026 14:34:48 +1100 Subject: [PATCH 4/5] fix(app): scope the CRT text glow with a module class so the production build passes --- packages/app/src/components/CrtOverlay.module.scss | 5 ++--- packages/app/src/components/CrtOverlay.tsx | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/app/src/components/CrtOverlay.module.scss b/packages/app/src/components/CrtOverlay.module.scss index b0525eccd..21d064ca3 100644 --- a/packages/app/src/components/CrtOverlay.module.scss +++ b/packages/app/src/components/CrtOverlay.module.scss @@ -90,9 +90,8 @@ } } -// Chromatic aberration and phosphor glow on all text. -/* stylelint-disable-next-line selector-pseudo-class-no-unknown */ -:global(html[data-crt]) body { +// Chromatic aberration and phosphor glow on all text. `.root` goes on . +.root body { text-shadow: 0.6px 0 rgb(255 0 80 / 35%), -0.6px 0 rgb(0 200 255 / 35%), diff --git a/packages/app/src/components/CrtOverlay.tsx b/packages/app/src/components/CrtOverlay.tsx index 89d26635c..d1cca7eb2 100644 --- a/packages/app/src/components/CrtOverlay.tsx +++ b/packages/app/src/components/CrtOverlay.tsx @@ -5,9 +5,9 @@ import styles from './CrtOverlay.module.scss'; /** Full-viewport CRT effect. Mount only while the preference is on. */ export function CrtOverlay() { useEffect(() => { - // Lets the global text glow in the stylesheet apply without a body class. - document.documentElement.setAttribute('data-crt', ''); - return () => document.documentElement.removeAttribute('data-crt'); + // A module class, not a global selector: the production build rejects those. + document.documentElement.classList.add(styles.root); + return () => document.documentElement.classList.remove(styles.root); }, []); return ( From a6d7ba60189ec191348b302345f0417601ad895b Mon Sep 17 00:00:00 2001 From: Jordan Simonovski Date: Wed, 18 Nov 2026 15:22:08 +1100 Subject: [PATCH 5/5] fix(app): address CRT mode review findings Name the switch for screen readers, keep it visible after CRT mode is turned off, and render the unlock flash outside the modal so it covers the viewport. Adds tests for turning the mode off and for the overlay's class on . --- packages/app/src/UserPreferencesModal.tsx | 15 ++++++++++++--- .../src/__tests__/UserPreferencesModal.test.tsx | 9 +++++++++ packages/app/src/components/CrtUnlockReveal.tsx | 6 +++++- .../src/components/__tests__/CrtOverlay.test.tsx | 13 +++++++++++++ 4 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 packages/app/src/components/__tests__/CrtOverlay.test.tsx diff --git a/packages/app/src/UserPreferencesModal.tsx b/packages/app/src/UserPreferencesModal.tsx index c814d336b..273693814 100644 --- a/packages/app/src/UserPreferencesModal.tsx +++ b/packages/app/src/UserPreferencesModal.tsx @@ -71,9 +71,17 @@ export const UserPreferencesModal = ({ useKonamiCode( React.useCallback(() => opened && setCrtUnlocked(true), [opened]), ); + // Stays true once CRT mode has been on while the modal is open, so turning + // the switch off does not remove it mid-click. + const [crtVisible, setCrtVisible] = React.useState(false); React.useEffect(() => { - if (!opened) setCrtUnlocked(false); - }, [opened]); + if (!opened) { + setCrtUnlocked(false); + setCrtVisible(false); + } else if (userPreferences.crtMode) { + setCrtVisible(true); + } + }, [opened, userPreferences.crtMode]); const crtSetting = ( setUserPreference({ crtMode: e.currentTarget.checked })} /> @@ -204,7 +213,7 @@ export const UserPreferencesModal = ({ {crtUnlocked ? ( {crtSetting} ) : ( - userPreferences.crtMode && crtSetting + crtVisible && crtSetting )} diff --git a/packages/app/src/__tests__/UserPreferencesModal.test.tsx b/packages/app/src/__tests__/UserPreferencesModal.test.tsx index 62d8bb9aa..abc33a817 100644 --- a/packages/app/src/__tests__/UserPreferencesModal.test.tsx +++ b/packages/app/src/__tests__/UserPreferencesModal.test.tsx @@ -144,5 +144,14 @@ describe('UserPreferencesModal', () => { expect(screen.getByTestId('crt-mode-switch')).toBeChecked(); }); + + it('keeps the toggle after CRT mode is turned off', async () => { + renderModal({ crtMode: true }); + + await userEvent.click(screen.getByRole('switch', { name: 'CRT mode' })); + + expect(readStoredPreferences().crtMode).toBe(false); + expect(screen.getByTestId('crt-mode-switch')).not.toBeChecked(); + }); }); }); diff --git a/packages/app/src/components/CrtUnlockReveal.tsx b/packages/app/src/components/CrtUnlockReveal.tsx index c7ace0104..69f4385f3 100644 --- a/packages/app/src/components/CrtUnlockReveal.tsx +++ b/packages/app/src/components/CrtUnlockReveal.tsx @@ -1,4 +1,5 @@ import * as React from 'react'; +import { Portal } from '@mantine/core'; import styles from './CrtUnlockReveal.module.scss'; @@ -17,7 +18,10 @@ export function CrtUnlockReveal({ children }: { children: React.ReactNode }) {
{children}
{playing && ( <> -
+ {/* The modal content has a transform, which would clip a fixed child to the modal. */} + +
+
{ + it('adds the root class to while mounted and removes it after', () => { + const { unmount } = render(); + expect(document.documentElement).toHaveClass('root'); + + unmount(); + expect(document.documentElement).not.toHaveClass('root'); + }); +});