[PR #5643] [MERGED] fix(client): keep keyboard focus through TTS voice-picker refetches; settle flaky geometry measurements #6862

Closed
opened 2026-10-23 04:14:24 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5643
Author: @kolacheee
Created: 8/29/2026
Status: ✅ Merged
Merged: 8/29/2026
Merged by: @kolacheee

Base: staging ← Head: fix/5642-wave3-flakes


📝 Commits (1)

  • c93847d fix(client): keep keyboard focus through TTS voice-picker refetches; settle geometry e2e measurements

📊 Changes

2 files changed (+152 additions, -71 deletions)

View changed files

📝 e2e/core-flows.e2e.ts (+96 -59)
📝 packages/client/src/components/panels/settings/TTSConfigCard.tsx (+56 -12)

📄 Description

Closes #5642

Why

Three desktop-chromium tests were failing intermittently on unrelated PRs (evidence in #5642: the same suite content flip-flopping between pass and fail across PR #5640's three matrix runs). One of them turned out to be a real accessibility bug, not test noise.

The ElevenLabs focus flake is an app bug — fixed in TTSConfigCard

The adversarial verification pass traced the full mechanism: every edit in the TTS card schedules a debounced autosave; its onSuccess invalidates the voices query; the refetch flips fetchingVoices, which disables every voice-picker trigger for a beat. Two ways that strands keyboard focus on <body>:

  • The searchable-select's disabled effect force-closes an open panel without restoring focus — the autofocused search input unmounts and focus silently dies. With few options (no search input), it's worse: the browser drops focus to <body> synchronously the moment the focused trigger's disabled attribute lands.
  • Even the Escape path's focus restore was a single requestAnimationFrame — and focus() on a disabled button is a silent no-op, never retried. A restore landing in the transient disabled window lost focus permanently.

That is exactly CI's toBeFocused → inactive (full 10s) at core-flows.e2e.ts:9560, and why it never reproduces locally (the mocked refetch closes the window in ~ms; 30/30 local baseline was green).

Fix: a bounded retrying restore (restoreFocusToTrigger) — retries across frames until the trigger accepts focus, 2s deadline, canceled on unmount, and aborts the moment focus legitimately lands on any real element so it can never steal from a user who moved on. The disabled-close path now restores too, when focus was inside the control (body counts, per the synchronous-drop behavior above). This is a real keyboard-user fix: previously any voices refetch while browsing a voice list dumped focus to <body>.

The test also gained a drain step: it now waits out the debounced autosave (and its voices refetch) before opening the per-character picker, closing the sibling window where the refetch could force-close the panel mid-measurement.

The two geometry flakes are measurement races — fixed in the tests

  • Tracker gutter (:6387, width 5.47px short): the getAnimations({subtree: true}) settle can see an empty registry for a transition that is scheduled but not started, so the one-shot measurement catches mid-transition geometry. The post-toggle measurements are now one retried unit (expect(...).toPass()), re-reading all boxes per attempt; the right-side re-anchor block got the same treatment (identical structure, CI just hadn't hit it yet). All assertions still compare against pre-toggle baselines, so a real layout regression fails terminally — verified in review that the retry cannot convert a genuine failure into a pass.
  • Home hub widget grid (:17148, ~77px spread): the measurements run right after the settings panel closes, and the six sequential width reads can sample different frames of the resize transition. Now anchored on the 4-column regime and wrapped in a retried unit; the later duplicate width check after the tab round-trip still provides the long-settled comparison.

Validation

  • Local baseline (pre-fix): 30/30 green — these flakes need CI-slow runners, so mechanism-level review was the main line of defense.
  • Post-fix: 30/30 green ×2 rounds (--repeat-each=10, --retries=0); final round includes every review-pass amendment.
  • pnpm check — passing.
  • Adversarial verification workflow (3 reviewers) confirmed the ElevenLabs mechanism end-to-end, verified the retried units cannot mask persistent regressions, and caught one real gap mid-review (a variable-scope error in the first tracker rework, plus the no-search-input focus variant) — both fixed before this PR.
  • Manually verify in browser: Settings → Connections → Text to Speech (ElevenLabs source) → open a voice picker, press Escape — focus returns to the picker button; repeat while a voices refresh is in flight.

Notes

  • Found in passing: the e2e specs are never type-checked by any lane (the root tsconfig includes them but nothing runs tsc on it) — that's how a scope error survived pnpm check. Left as a separate follow-up task rather than folding a large tsconfig effort into this PR.

Summary by CodeRabbit

  • Bug Fixes

    • Improved focus restoration when closing the voice selection menu.
    • Automatically closes the voice selection menu when disabled, while preserving focus appropriately.
    • Improved reliability during animated layout changes and delayed data updates.
  • Tests

    • Expanded end-to-end coverage for layout stability, autosave completion, voice loading, and responsive grid behavior.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/5643 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 8/29/2026 **Status:** ✅ Merged **Merged:** 8/29/2026 **Merged by:** [@kolacheee](https://github.com/kolacheee) **Base:** `staging` ← **Head:** `fix/5642-wave3-flakes` --- ### 📝 Commits (1) - [`c93847d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c93847db4d16c55b26d52b6e14fa8a2eda11835c) fix(client): keep keyboard focus through TTS voice-picker refetches; settle geometry e2e measurements ### 📊 Changes **2 files changed** (+152 additions, -71 deletions) <details> <summary>View changed files</summary> 📝 `e2e/core-flows.e2e.ts` (+96 -59) 📝 `packages/client/src/components/panels/settings/TTSConfigCard.tsx` (+56 -12) </details> ### 📄 Description Closes #5642 ## Why Three desktop-chromium tests were failing intermittently on unrelated PRs (evidence in #5642: the same suite content flip-flopping between pass and fail across PR #5640's three matrix runs). One of them turned out to be a real accessibility bug, not test noise. ## The ElevenLabs focus flake is an app bug — fixed in `TTSConfigCard` The adversarial verification pass traced the full mechanism: every edit in the TTS card schedules a debounced autosave; its `onSuccess` invalidates the voices query; the refetch flips `fetchingVoices`, which disables every voice-picker trigger for a beat. Two ways that strands keyboard focus on `<body>`: - The searchable-select's disabled effect force-closes an open panel **without restoring focus** — the autofocused search input unmounts and focus silently dies. With few options (no search input), it's worse: the browser drops focus to `<body>` synchronously the moment the focused trigger's `disabled` attribute lands. - Even the Escape path's focus restore was a single `requestAnimationFrame` — and `focus()` on a disabled button is a **silent no-op**, never retried. A restore landing in the transient disabled window lost focus permanently. That is exactly CI's `toBeFocused` → `inactive` (full 10s) at `core-flows.e2e.ts:9560`, and why it never reproduces locally (the mocked refetch closes the window in ~ms; 30/30 local baseline was green). Fix: a bounded retrying restore (`restoreFocusToTrigger`) — retries across frames until the trigger accepts focus, 2s deadline, canceled on unmount, and **aborts the moment focus legitimately lands on any real element** so it can never steal from a user who moved on. The disabled-close path now restores too, when focus was inside the control (body counts, per the synchronous-drop behavior above). This is a real keyboard-user fix: previously any voices refetch while browsing a voice list dumped focus to `<body>`. The test also gained a drain step: it now waits out the debounced autosave (and its voices refetch) before opening the per-character picker, closing the sibling window where the refetch could force-close the panel mid-measurement. ## The two geometry flakes are measurement races — fixed in the tests - **Tracker gutter** (`:6387`, width 5.47px short): the `getAnimations({subtree: true})` settle can see an empty registry for a transition that is scheduled but not started, so the one-shot measurement catches mid-transition geometry. The post-toggle measurements are now one retried unit (`expect(...).toPass()`), re-reading all boxes per attempt; the right-side re-anchor block got the same treatment (identical structure, CI just hadn't hit it yet). All assertions still compare against pre-toggle baselines, so a *real* layout regression fails terminally — verified in review that the retry cannot convert a genuine failure into a pass. - **Home hub widget grid** (`:17148`, ~77px spread): the measurements run right after the settings panel closes, and the six sequential width reads can sample different frames of the resize transition. Now anchored on the 4-column regime and wrapped in a retried unit; the later duplicate width check after the tab round-trip still provides the long-settled comparison. ## Validation - Local baseline (pre-fix): 30/30 green — these flakes need CI-slow runners, so mechanism-level review was the main line of defense. - Post-fix: 30/30 green ×2 rounds (`--repeat-each=10`, `--retries=0`); final round includes every review-pass amendment. - `pnpm check` — passing. - Adversarial verification workflow (3 reviewers) confirmed the ElevenLabs mechanism end-to-end, verified the retried units cannot mask persistent regressions, and caught one real gap mid-review (a variable-scope error in the first tracker rework, plus the no-search-input focus variant) — both fixed before this PR. - Manually verify in browser: Settings → Connections → Text to Speech (ElevenLabs source) → open a voice picker, press Escape — focus returns to the picker button; repeat while a voices refresh is in flight. ## Notes - Found in passing: the e2e specs are never type-checked by any lane (the root tsconfig includes them but nothing runs `tsc` on it) — that's how a scope error survived `pnpm check`. Left as a separate follow-up task rather than folding a large tsconfig effort into this PR. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved focus restoration when closing the voice selection menu. * Automatically closes the voice selection menu when disabled, while preserving focus appropriately. * Improved reliability during animated layout changes and delayed data updates. * **Tests** * Expanded end-to-end coverage for layout stability, autosave completion, voice loading, and responsive grid behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:14:24 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#6862
No description provided.