Skip to content

refactor(layout): move the dialog hub out of AppLayout - #612

Merged
EVWorth merged 1 commit into
mainfrom
refactor/applayout-dialog-hub
Sep 10, 2026
Merged

EVWorth merged 1 commit into
mainfrom
refactor/applayout-dialog-hub

Conversation

@EVWorth

@EVWorth EVWorth commented Sep 10, 2026

Copy link
Copy Markdown
Owner

Closes #450. Last of the cross-cutting audit.

AppLayout was the layout shell, the menu dispatcher and the dialog hub at once. Seven useState pairs held which dialog was open and what it was opened against, so every route that wanted to open one — the menu switch, the sidebar's context menus, the toolbar — had to reach into this component, and adding a dialog meant editing the layout shell. The backup and restore pre-select state was copy-pasted between the two.

dialogStore holds it instead. AppLayout still renders the dialogs; anything that wants one open says so from where it is.

369 → 345 lines, 11 useState → 4.

One thing the shared state makes possible to get wrong

The target is replaced rather than merged when a dialog opens. Two separate copy-pasted preselect states couldn't get this wrong; one shared one can — and inheriting the connection a previous context-menu open selected is how you back up the wrong database. There's a test.

The ConfirmDialog half was already closed

#588 replaced the hardcoded destructive-query confirm with a general, awaitable gate that four features now use. Recording that here rather than leaving it to be rediscovered.

A test-isolation note

AppLayout's tests gained a reset for the new module-level state. They pass without it today, but a test that opens a dialog would otherwise leave it open for the next.

Verification

9 new store tests. The existing AppLayout tests exercise the event→dialog path end-to-end and still pass, which is what says the extraction preserved behaviour. Unit 2035, browser 297, 0 lint errors.

AppLayout was the layout shell, the menu dispatcher and the dialog hub at
once (#450). Seven useState pairs held which dialog was open and what it was
opened against, so every route that wanted to open one — the menu switch,
the sidebar's context menus, the toolbar — had to reach into this component,
and adding a dialog meant editing the layout shell. The backup and restore
pre-select state was copy-pasted between the two.

dialogStore holds it instead. AppLayout still renders the dialogs; anything
that wants one open says so from where it is. 369 lines to 345, and eleven
useState calls to four.

The target is replaced rather than merged when a dialog opens. Two separate
copy-pasted preselect states could not get this wrong; one shared one can,
and inheriting the connection a previous context-menu open selected is how
you back up the wrong database. There is a test.

The ConfirmDialog half of this issue was already closed by #588: the
production gate is a general, awaitable confirm now rather than one
hardcoded to destructive-query copy, and four features use it.

AppLayout's own tests gained a reset for the new module-level state. They
pass without it today, but a test that opens a dialog would otherwise leave
it open for the next one.

Closes #450

Co-Authored-By: Claude Opus 5 <[email protected]>
@EVWorth
EVWorth merged commit e1166e2 into main Sep 10, 2026
12 checks passed
@EVWorth
EVWorth deleted the refactor/applayout-dialog-hub branch September 10, 2026 04:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P1][arch] AppLayout.tsx is layout shell + menu dispatcher + dialog hub — 306 LOC, 13 useState pairs

1 participant