Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review (claude): track hover and focus pause independently in DrillTransition

Adam Eivy4f44d750af9d
diff --git a/client/src/components/meatspace/post/DrillTransition.jsx b/client/src/components/meatspace/post/DrillTransition.jsx
index 5e9a093f97..59806658c5 100644
--- a/client/src/components/meatspace/post/DrillTransition.jsx
+++ b/client/src/components/meatspace/post/DrillTransition.jsx
@@ -13,11 +13,16 @@ const DOMAIN_ICONS = {
export default function DrillTransition({ nextDrillType, drillIndex, drillCount, completedResults, onContinue }) {
const [countdown, setCountdown] = useState(3);
// Explicit user pause (Pause/Resume button) vs. transient hover/focus pause —
- // tracked separately so releasing hover/focus doesn't silently un-pause a
- // deliberate Pause click. Either one halts the countdown.
+ // tracked separately so releasing one doesn't silently un-pause another.
+ // Hover and focus are ALSO tracked independently of each other (not
+ // collapsed into one boolean): a mouseleave while a control inside the
+ // card still holds keyboard focus must not resume the countdown, and vice
+ // versa for blur while the mouse is still over the card. Any of the three
+ // being true halts the countdown.
const [manuallyPaused, setManuallyPaused] = useState(false);
- const [hovering, setHovering] = useState(false);
- const paused = manuallyPaused || hovering;
+ const [hoveringMouse, setHoveringMouse] = useState(false);
+ const [hoveringFocus, setHoveringFocus] = useState(false);
+ const paused = manuallyPaused || hoveringMouse || hoveringFocus;
const domainKey = DRILL_TO_DOMAIN[nextDrillType];
const domain = domainKey ? DOMAINS[domainKey] : null;
@@ -37,14 +42,16 @@ export default function DrillTransition({ nextDrillType, drillIndex, drillCount,
return (
<div
className="max-w-lg mx-auto space-y-8"
- onMouseEnter={() => setHovering(true)}
- onMouseLeave={() => setHovering(false)}
- onFocus={() => setHovering(true)}
+ onMouseEnter={() => setHoveringMouse(true)}
+ onMouseLeave={() => setHoveringMouse(false)}
+ onFocus={() => setHoveringFocus(true)}
onBlur={(e) => {
- // Only clear hover-pause once focus has left the whole transition card,
+ // Only clear focus-pause once focus has left the whole transition card,
// not just the individual button — a Tab between the Pause and Continue
- // buttons shouldn't flicker the countdown back on mid-transition.
- if (!e.currentTarget.contains(e.relatedTarget)) setHovering(false);
+ // buttons shouldn't flicker the countdown back on mid-transition. This
+ // is independent of hoveringMouse, so leaving the card with the mouse
+ // while a control still holds focus (or vice versa) can't resume it.
+ if (!e.currentTarget.contains(e.relatedTarget)) setHoveringFocus(false);
}}
>
{/* Completed domains summary */}
diff --git a/client/src/components/meatspace/post/DrillTransition.test.jsx b/client/src/components/meatspace/post/DrillTransition.test.jsx
index 25625ae71b..35d590bf2f 100644
--- a/client/src/components/meatspace/post/DrillTransition.test.jsx
+++ b/client/src/components/meatspace/post/DrillTransition.test.jsx
@@ -95,4 +95,32 @@ describe('DrillTransition', () => {
await tickSeconds(5);
expect(onContinue).not.toHaveBeenCalled();
});
+
+ it('a focus-driven pause survives the mouse leaving the card (hover and focus are independent)', async () => {
+ // Regression: hover and focus used to collapse into one boolean, so a
+ // mouseleave while a control still held keyboard focus silently resumed
+ // the countdown even though the user never blurred the focused control.
+ const onContinue = vi.fn();
+ const { container } = render(<DrillTransition {...baseProps} onContinue={onContinue} />);
+ const card = container.firstChild;
+ fireEvent.mouseEnter(card);
+ fireEvent.focus(screen.getByRole('button', { name: 'Pause' }));
+ fireEvent.mouseLeave(card);
+ await tickSeconds(5);
+ expect(onContinue).not.toHaveBeenCalled();
+ });
+
+ it('a hover-driven pause survives a blur inside the card (focus and hover are independent)', async () => {
+ // Mirror of the above: leaving keyboard focus (blur) while the mouse is
+ // still hovering the card must not resume the countdown either.
+ const onContinue = vi.fn();
+ const { container } = render(<DrillTransition {...baseProps} onContinue={onContinue} />);
+ const card = container.firstChild;
+ const pauseButton = screen.getByRole('button', { name: 'Pause' });
+ fireEvent.focus(pauseButton);
+ fireEvent.mouseEnter(card);
+ fireEvent.blur(pauseButton, { relatedTarget: null });
+ await tickSeconds(5);
+ expect(onContinue).not.toHaveBeenCalled();
+ });
});