A local-first personal finance app
[AI] Replace any-typed Modal in undo state with structural type (#7813)
Matiss Janis Aboltins6c1699f0b079
diff --git a/packages/desktop-client/src/global-events.ts b/packages/desktop-client/src/global-events.tsindex 3413f18177..cda472f1c2 100644--- a/packages/desktop-client/src/global-events.ts+++ b/packages/desktop-client/src/global-events.ts@@ -8,6 +8,7 @@ import { setAppState } from './app/appSlice';import { categoryQueries } from './budget';import { closeBudgetUI } from './budgetfiles/budgetfilesSlice';import { closeModal, pushModal, replaceModal } from './modals/modalsSlice';+import type { Modal } from './modals/modalsSlice';import {addGenericErrorNotification,addNotification,@@ -90,13 +91,19 @@ export function handleGlobalEvents(store: AppStore, queryClient: QueryClient) {// If a modal has been tagged, open it instead of navigatingif (tagged.openModal) {+ // The undo store keeps modals as an opaque structural shape; re-narrow+ // to the real Modal union now that we're back in desktop-client.+ // TODO: drop this cast once the Modal type lives somewhere both+ // loot-core and desktop-client can import (e.g. consolidated under+ // @actual-app/core types).+ const openModal = tagged.openModal as Modal;const { modalStack } = store.getState().modals;if (modalStack.length === 0 ||- modalStack[modalStack.length - 1].name !== tagged.openModal.name+ modalStack[modalStack.length - 1].name !== openModal.name) {- store.dispatch(replaceModal({ modal: tagged.openModal }));+ store.dispatch(replaceModal({ modal: openModal }));}} else {store.dispatch(closeModal());diff --git a/packages/loot-core/src/platform/client/undo/index.ts b/packages/loot-core/src/platform/client/undo/index.tsindex 13991aa528..4481ee8463 100644--- a/packages/loot-core/src/platform/client/undo/index.ts+++ b/packages/loot-core/src/platform/client/undo/index.ts@@ -2,8 +2,10 @@ import { v4 as uuidv4 } from 'uuid';import type { UndoState as ServerUndoState } from '#server/undo';-// oxlint-disable-next-line @typescript-eslint/no-explicit-any-type Modal = any; // TODO: fix me+// Minimal structural shape of desktop-client's Modal union. loot-core can't+// import the full type from @actual-app/web; the undo system only stores the+// modal and reads `name`. `options` is kept loose so the real Modal assigns.+type Modal = { name: string; options?: unknown };type UndoState = {url: string | null;diff --git a/upcoming-release-notes/7813.md b/upcoming-release-notes/7813.mdnew file mode 100644index 0000000000..582226759a--- /dev/null+++ b/upcoming-release-notes/7813.md@@ -0,0 +1,6 @@+---+category: Maintenance+authors: [MatissJanis]+---++Replace any-typed Modal in undo state with a defined structural type.