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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: order Alt+Shift+N's newest-toast lookup by recency, not array index (#8117)
[._.]/ Adam Eivyf4e3547307b8
diff --git a/client/src/components/ui/Toast.jsx b/client/src/components/ui/Toast.jsxindex e0aaa8ad61..c8fe6443e2 100644--- a/client/src/components/ui/Toast.jsx+++ b/client/src/components/ui/Toast.jsx@@ -16,6 +16,7 @@ import { uuidv4 } from '../../lib/uuid.js';import { isEditableTarget } from '../../lib/a11yKeyboard.js';let toasts = [];+let toastSeq = 0;const listeners = new Set();function notify() {@@ -90,7 +91,12 @@ function add(content, opts = {}, type = 'default') {const collapseAfter = Number.isFinite(opts.collapseAfter) && opts.collapseAfter > 0? opts.collapseAfter: COLLAPSE_AFTER_MS;- const entry = { id, type, content, icon: opts.icon, duration, style: opts.style, label: opts.label, collapseAfter };+ // `seq` marks WHEN this entry was last touched, independent of its+ // position in `toasts` — a same-id re-add (loading→success) replaces the+ // entry IN PLACE at its original array index so the stack doesn't jump, so+ // array order alone can't answer "which toast is newest" once an update+ // has happened. The Alt+Shift+N jump below reads this instead of `[last]`.+ const entry = { id, type, content, icon: opts.icon, duration, style: opts.style, label: opts.label, collapseAfter, seq: ++toastSeq };const idx = toasts.findIndex(t => t.id === id);toasts = idx !== -1@@ -163,7 +169,10 @@ export function Toaster({ position = 'bottom-right', toastOptions = {} }) {// guard does for the shortcut hooks that route through it.if (document.querySelector('[aria-modal="true"]')) return;const region = regionRef.current;- const newest = items[items.length - 1];+ // `seq`, not array position — a same-id re-add (loading→success)+ // replaces the entry in place at its original index, so the LAST+ // item isn't necessarily the one most recently touched.+ const newest = items.reduce((a, b) => (!a || b.seq > a.seq ? b : a), null);if (!region || !newest) return;const toastEl = region.querySelector(`[data-toast-id="${newest.id}"]`);if (!toastEl) return;diff --git a/client/src/components/ui/Toast.test.jsx b/client/src/components/ui/Toast.test.jsxindex acbfe972f2..913538567e 100644--- a/client/src/components/ui/Toast.test.jsx+++ b/client/src/components/ui/Toast.test.jsx@@ -449,6 +449,28 @@ describe('Alt+Shift+N focuses the newest toast, and Escape returns focus', () =>expect(document.activeElement).toBe(screen.getByRole('button', { name: 'Undo' }));});+ it('follows a same-id update to an older toast, not just the last one added', () => {+ // Regression: `add()` replaces a same-id entry IN PLACE at its original+ // array index (so the stack doesn't visually jump), so "the last item in+ // the array" stops being "the most recently touched toast" once an+ // earlier one gets updated after a later one was added.+ render(<Toaster />);+ act(() => {+ toast(() => <button type="button">First Undo</button>, { id: 'first', duration: Infinity, label: 'First' });+ });+ act(() => {+ toast(() => <span>Second, unrelated</span>, { id: 'second', duration: Infinity, label: 'Second' });+ });+ // Update the FIRST (older, lower array index) toast — it's now the most+ // recently touched, even though it isn't last in the array.+ act(() => {+ toast(() => <button type="button">Updated Undo</button>, { id: 'first', duration: Infinity, label: 'First' });+ });++ pressJumpShortcut();+ expect(document.activeElement).toBe(screen.getByRole('button', { name: 'Updated Undo' }));+ });+it('holds the toast open once the jump lands focus inside it, even past its duration', () => {render(<Toaster />);act(() => {