Dashboard keyboard shortcuts now toggle their associated dashboard interfaces. - Dispatch toggle callbacks for every configurable dashboard shortcut. - Restore retained prior views and preserve repeated Settings/Command Center history entries. - Add regression coverage, documentation, and a dashboard feature changeset. Files changed: .changeset/fn-8069-shortcut-toggle.md | 7 + docs/dashboard-guide.md | 3 + packages/dashboard/app/App.tsx | 48 ++++-- .../app/__tests__/App.keyboard-shortcuts.test.tsx | 172 +++++++++++++++++---- .../useDashboardKeyboardShortcuts.test.tsx | 82 +++++----- .../app/hooks/useDashboardKeyboardShortcuts.ts | 40 ++--- .../app/utils/dashboardShortcutToggles.ts | 41 +++++ 7 files changed, 290 insertions(+), 103 deletions(-) Fusion-Task-Id: FN-8069 Fusion-Task-Lineage: c2e6d67a-d215-46dd-9803-78ffb49fbbda Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
/*
|
|
FNXC:DashboardShortcuts 2026-07-16-00:00:
|
|
FN-8069 requires view-backed dashboard shortcuts to remove the exact navigation-history callback that opened their view, then restore the captured prior view. Retain a callback stack per view so repeated Settings/Command Center entries each preserve their own history; keep this identity-sensitive lifecycle outside App's render body for live navigation-history regression coverage (Runfusion/Fusion#2118).
|
|
*/
|
|
export function retainViewNavRevert<TView>(
|
|
view: TView,
|
|
previousView: TView,
|
|
reverts: Map<TView, (() => void)[]>,
|
|
restoreView: (view: TView) => void,
|
|
): () => void {
|
|
const revert = () => {
|
|
const viewReverts = reverts.get(view);
|
|
if (viewReverts) {
|
|
const index = viewReverts.lastIndexOf(revert);
|
|
if (index !== -1) viewReverts.splice(index, 1);
|
|
if (viewReverts.length === 0) reverts.delete(view);
|
|
}
|
|
restoreView(previousView);
|
|
};
|
|
const viewReverts = reverts.get(view) ?? [];
|
|
viewReverts.push(revert);
|
|
reverts.set(view, viewReverts);
|
|
return revert;
|
|
}
|
|
|
|
export function closeViewShortcut<TView>(
|
|
view: TView,
|
|
reverts: Map<TView, (() => void)[]>,
|
|
removeNav: (revert: () => void) => void,
|
|
onMissingRevert: () => void,
|
|
): boolean {
|
|
const viewReverts = reverts.get(view);
|
|
const revert = viewReverts?.at(-1);
|
|
if (!revert) {
|
|
onMissingRevert();
|
|
return false;
|
|
}
|
|
removeNav(revert);
|
|
revert();
|
|
return true;
|
|
}
|