diff --git a/docs/plans/2026-10-29-topbar-scroll-glitch.md b/docs/plans/2026-10-29-topbar-scroll-glitch.md new file mode 100644 index 0000000..390a373 --- /dev/null +++ b/docs/plans/2026-10-29-topbar-scroll-glitch.md @@ -0,0 +1,29 @@ +# Topbar scroll glitch + +Scrolling down and back to the top shows visual glitches in the top bar and the +Home/History/Dictionary/Settings navigation: content shows through (reported +with the mouse wheel). + +- [x] Reproduce the glitch in WebKitGTK (the engine the Tauri app uses) with captured frames +- [x] Identify the root cause from the reproduction +- [x] Failing test: switching views resets the scroll position of `main` +- [x] Shell layout: only `main` scrolls, topbar and nav are not sticky; scroll reset targets `main` +- [x] Same reproduction no longer shows the glitch +- [x] e2e fit check also covers horizontal overflow inside `main` +- [x] Frontend CI checks pass locally (typecheck, lint, tests, responsive e2e) +- [ ] PR filed, reviews addressed, required checks green +- [ ] PR merged + +## Findings + +- Reproduced only on native Wayland (in-process capture of the frames WebKit + hands to GTK while sending smooth wheel deltas). XWayland and Xvfb never + showed it. +- Baseline: 12, 27 (920 wide) and 22 (1280 wide) of 420 frames had the sticky + topbar or nav drawn out of place with content showing through. +- `content-visibility: visible` on transcript rows: 11 and 20 of 420, so not the cause. +- Only `main` scrolling (bars not sticky): 0 of 420 in three runs, at 920 and 1280. +- The user confirmed on their machine: the glitch shows in the old build and not in the fixed one. +- Screen recordings of the user's own mouse scrolling on Home (GNOME screencast, + bar region checked frame by frame): old build 21 of 1558 frames with the top + bar displaced 15 to 30px; fixed build 0 of 1515. diff --git a/frontend/e2e/ui-design.spec.ts b/frontend/e2e/ui-design.spec.ts index 661867d..8a5bcf3 100644 --- a/frontend/e2e/ui-design.spec.ts +++ b/frontend/e2e/ui-design.spec.ts @@ -20,9 +20,11 @@ async function capture(page: Page, info: TestInfo, name: string) { } async function expectFits(page: Page) { - expect(await page.evaluate(() => - document.documentElement.scrollWidth <= document.documentElement.clientWidth, - )).toBe(true) + expect(await page.evaluate(() => { + const fits = (node: Element) => node.scrollWidth <= node.clientWidth + const main = document.querySelector('main.main-content') + return fits(document.documentElement) && main !== null && fits(main) + })).toBe(true) } for (const theme of ['light', 'dark']) { diff --git a/frontend/src/App.test.tsx b/frontend/src/App.test.tsx index cf65941..ddeb821 100644 --- a/frontend/src/App.test.tsx +++ b/frontend/src/App.test.tsx @@ -185,6 +185,30 @@ describe('Echo desktop shell', () => { expect(screen.getByPlaceholderText('Search transcripts…')).toBeInTheDocument() }) + it('opens each view at the top of the scrolling content area', async () => { + render() + const main = screen.getByRole('main') + main.scrollTop = 240 + + fireEvent.click(screen.getByRole('button', { name: 'History' })) + + expect(await screen.findByRole('heading', { name: 'History' })).toBeInTheDocument() + expect(main.scrollTop).toBe(0) + }) + + it('focuses the scrolling content area so the keyboard scrolls it', async () => { + render() + const main = screen.getByRole('main') + expect(main).toHaveFocus() + + const history = screen.getByRole('button', { name: 'History' }) + history.focus() + fireEvent.click(history) + + expect(await screen.findByRole('heading', { name: 'History' })).toBeInTheDocument() + expect(main).toHaveFocus() + }) + it.each([ ['Transcribing', 'Transcribing locally…', 'Whisper · small · VAD on is turning your recording into text.'], ['Injecting', 'Inserting transcript…', 'ydotool · Wayland is sending your transcript to the active app.'], diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 8b85e95..eccc8f4 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -6,6 +6,7 @@ import { Power, Settings, } from 'lucide-react' +import { useEffect, useRef } from 'react' import { BrandMark, StatusPill } from './app/chrome' import { useAppController } from './app/useAppController' import { DictionaryView } from './dictionary/DictionaryView' @@ -47,6 +48,14 @@ function App() { removeDictionaryEntry, } = useAppController() const shortcut = presentShortcut(status.shortcut) + const mainRef = useRef(null) + + // main is the only scroller, so it needs focus for keyboard scrolling. + useEffect(() => { + if (!mainRef.current) return + mainRef.current.scrollTop = 0 + mainRef.current.focus({ preventScroll: true }) + }, [view]) return (
@@ -103,7 +112,7 @@ function App() {
-
+
{error ? (