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 (codex): hold the toast open on hover and focus independently

[._.]/ Adam Eivy9af1539b1a4c
diff --git a/client/src/components/ui/Toast.jsx b/client/src/components/ui/Toast.jsx
index 9c71c97346..b89b3b9615 100644
--- a/client/src/components/ui/Toast.jsx
+++ b/client/src/components/ui/Toast.jsx
@@ -171,7 +171,16 @@ function ToastItem({ t, toastOptions }) {
// collapsing out from under a hover would yank the buttons the user is
// reaching for, and collapsing while focus is inside would drop that focus
// to <body>.
- const [held, setHeld] = useState(false);
+ //
+ // Two flags, not one: hover and focus are independent holds, and a single
+ // shared boolean lets whichever ends last clear the other's. Tab to the
+ // toast's button, then sweep the pointer over the toast and off again, and
+ // `mouseleave` would release a hold that focus still owns — 8s later the
+ // still-focused button gets `display: none` and focus lands on <body>, the
+ // exact thing this is here to prevent.
+ const [hovered, setHovered] = useState(false);
+ const [focusWithin, setFocusWithin] = useState(false);
+ const held = hovered || focusWithin;
const collapseAfter = t.collapseAfter ?? COLLAPSE_AFTER_MS;
@@ -223,11 +232,13 @@ function ToastItem({ t, toastOptions }) {
<div
style={bodyStyle}
role={t.type === 'error' ? 'alert' : 'status'}
- onMouseEnter={() => setHeld(true)}
- onMouseLeave={() => setHeld(false)}
- // onFocus/onBlur bubble in React, so these fire for the toast's buttons too.
- onFocus={() => setHeld(true)}
- onBlur={() => setHeld(false)}
+ onMouseEnter={() => setHovered(true)}
+ onMouseLeave={() => setHovered(false)}
+ // onFocus/onBlur bubble in React, so these fire for the toast's buttons
+ // too. Moving between two buttons inside the toast fires blur then
+ // focus; both land in one batch, so the hold never blips false.
+ onFocus={() => setFocusWithin(true)}
+ onBlur={() => setFocusWithin(false)}
className="pointer-events-auto flex items-start gap-2 shadow-lg text-sm max-w-[calc(100vw-2rem)] sm:max-w-[520px] bg-port-card border border-port-border">
{iconStr && <span className={`shrink-0 ${iconClass}`} aria-hidden="true">{iconStr}</span>}
<div className="flex-1 min-w-0">
diff --git a/client/src/components/ui/Toast.test.jsx b/client/src/components/ui/Toast.test.jsx
index 1a03b33430..393e7dd902 100644
--- a/client/src/components/ui/Toast.test.jsx
+++ b/client/src/components/ui/Toast.test.jsx
@@ -143,6 +143,50 @@ describe('long-lived toasts stop blocking the page', () => {
expect(screen.queryByRole('button', { name: /show notification/i })).toBeNull();
});
+ it('keeps focus held even after the pointer sweeps over the toast and leaves', () => {
+ // Hover and focus are independent holds. A single shared flag lets the
+ // pointer leaving release a hold that focus still owns, and the collapse
+ // then `display: none`s the very button the keyboard user is sitting on.
+ act(() => {
+ toast(() => <button type="button">Reconcile now</button>, {
+ duration: Infinity,
+ label: 'Install out of sync',
+ });
+ });
+
+ const button = screen.getByRole('button', { name: 'Reconcile now' });
+ const body = screen.getByRole('status');
+
+ fireEvent.focus(button); // keyboard user tabs in
+ fireEvent.mouseEnter(body); // pointer drifts across the toast
+ fireEvent.mouseLeave(body); // and off again — focus is still inside
+
+ advance(COLLAPSE_AFTER_MS * 2);
+ expect(screen.getByRole('button', { name: 'Reconcile now' })).toBeVisible();
+
+ // Once focus actually leaves, nothing is holding it open any more.
+ fireEvent.blur(button);
+ advance(COLLAPSE_AFTER_MS);
+ expect(screen.getByRole('button', { name: 'Show notification: Install out of sync' })).toBeVisible();
+ });
+
+ it('keeps hover held even after focus leaves the toast', () => {
+ // The mirror image: focus departing must not release the pointer's hold.
+ act(() => { toast('Update available', { duration: Infinity }); });
+
+ const body = screen.getByRole('status');
+ fireEvent.mouseEnter(body);
+ fireEvent.focus(body);
+ fireEvent.blur(body);
+
+ advance(COLLAPSE_AFTER_MS * 2);
+ expect(screen.getByRole('status')).toBeVisible();
+
+ fireEvent.mouseLeave(body);
+ advance(COLLAPSE_AFTER_MS);
+ expect(screen.getByRole('button', { name: 'Show notification: Update available' })).toBeVisible();
+ });
+
it('folds on the content\'s own schedule when it passes collapseAfter', () => {
// The agent-feedback card sets duration: Infinity only because it runs a
// 15s dismiss of its own. Folding at the 8s default would hide its rating