Repository navigation
Refactor/frontend modular monolith - #454
Merged
Merged
Conversation
… folders Moves every file into the modular-monolith layout, with history kept: - app/: entry point, routing, layout shell, command palette, auth screens - core/: API transport, auth, backend, errors, toasts, socket, theme - shared/: generic UI components, hooks, helpers and editor resources - features/<id>/: one folder per dashboard section, holding its page, components, hooks and tests, plus Chat Ops as features/chat Components and helpers used by a single feature move into it. Imports within one unit stay relative, and imports across units use the layer aliases. No behaviour changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…anifests Each feature folder now exports a manifest from its index.ts: route and lazy page, nav entry, roomy layout flag, palette links and data sources, shortcuts, and an optional shell component. app/registry.ts discovers them with import.meta.glob, so deleting a feature folder removes it from the build with no other edits. - core/features.ts holds the registry, featureHref() and hasFeature(). Links between features go through it and disappear when the target feature is missing; shared/ui/FeatureLink wraps that for JSX. - App routes, Layout navigation, the command palette, the shortcuts overview and the dashboard guide read the registry instead of the hardcoded sections list, which is removed. - Chat Ops moves out of Layout into features/chat/ChatShell, adding its footer button, palette action and Ctrl+. through core/shellActions. The dashboard tour registers its palette action the same way. - The Chat Ops turn event moves to core, ProgressDialog back to shared, and the designer sandbox test next to the designer. - App, Layout, palette and shortcuts tests run against stand-in features; each feature tests its own palette source. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…yout A feature folder now keeps only its manifest (index.ts) at the root. React components move into components/, plain TypeScript into lib/, hooks stay in hooks/ and tests in test/. The generator's rule wizards move under components/wizards/. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
core/api.ts keeps the transport and the calls the shell, shared code or several features make (about half). Every call, type and helper only one feature uses moves to features/<id>/lib/api.ts, built on the http helper core exports, so the call leaves with its feature. The core API tests' cases for moved calls move with them into each feature's test/api.test.ts, on a shared fetch stand-in in src/test/fetchMock.ts. Feature tests that mock core/api also mock their own api module. The suite keeps all 2814 tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rules whose classes only one feature uses move from app/styles.css to features/<id>/styles/<id>.css, imported by the feature's manifest, so they load after the global sheet and leave with the feature. About 2,000 lines move; the global sheet goes from 7,123 to 5,052 lines. Loading later can only change the cascade where a later global rule of the same specificity styles the same element, so any moved rule with such a candidate stays global (162 rules). The rule set is unchanged: all 927 rules are still present with identical declarations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s removable - eslint-plugin-boundaries: a feature may import only itself, core, shared and the test helpers; app, core and shared may not import a feature. Violations fail npm run lint. - npm run check:removable typechecks, builds and tests a copy of the frontend without each feature in turn (or the ones named). All 16 features pass. - Tests that link into another feature register a stand-in for it (src/test/features.ts), so they hold in a build without it. - Unit tests for the registry and FeatureLink, and a race fixed in the Chat Ops shell test that showed under load. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e layout - core/ merges into shared/, grouped by area: api/ (transport, shared calls, socket), auth/ (context, stored backends), shell/ (feature registry, shell actions, shortcuts, Chat Ops events) and lib/ (errors, toasts, nav guard, theme, font, support). The @core alias is gone, and the boundary rules have three layers: app, shared, features. - app/ gets the same layout as a feature: routes/AppRoutes.tsx (the login gates and route table, was App.tsx), pages/ (not-found and the auth screens), components/, lib/ (feature discovery, OIDC), styles/. - Each feature's routed page moves from components/ to pages/. Moves only, no behaviour change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… failure regex SonarCloud: the shared API module exported its mutable baseUrl (S6861), which nothing outside the module reads; apiBaseUrl() is the accessor. The removability check's failure filter now groups its alternatives. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
1 of 4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



What this does
Turns the frontend into a modular monolith: every folder under
frontend/src/features/can be deleted and the app still typechecks, builds and passes its tests. Nothing else needs editing when a feature is added or removed.src/now has three layers, each with a path alias:app/@app/main.tsx,routes/AppRoutes.tsx(login gates + route table),pages/(not-found, auth screens),components/(layout, palette, dialogs),lib/,styles/shared/@shared/api/,auth/,shell/(feature registry, shell actions, shortcuts),lib/,hooks/,ui/,resources/features/<id>/@features/chat)No behaviour change is intended. Every page, link and shortcut works as before when all features are present.
How a feature plugs in
index.ts: route and lazy page, nav entry, palette links and data sources, shortcuts, and an optionalshellcomponent the layout keeps mounted (Chat Ops uses this).app/lib/registry.tsfinds manifests withimport.meta.glob.sections.tsxis gone).featureHref(id, suffix)/<FeatureLink>, which render nothing when the target feature is missing.shared/shell/shellActions.ts.index.tsat the root, the rest inpages/(the routed page),components/,hooks/,lib/,styles/andtest/.lib/api.ts. The shared API module (shared/api/index.ts) went from 2,331 to ~1,150 lines.styles/<id>.css(~2,000 lines moved out of the global sheet, nowapp/styles/app.css).How it's enforced
eslint-plugin-boundariesinnpm run lint: a feature imports only itself,sharedand the test helpers, andappandsharednever import a feature.npm run check:removabletypechecks, builds and tests a copy of the frontend without each feature in turn. All 16 features pass. It takes ~15 minutes, so it isn't in CI or the hooks;-- <id>checks one feature.Review notes
reorganise src…,components, lib and hooks layout,fold core into shared…) are mechanical moves with import rewrites, and git shows them as renames.app/styles/app.css, so a rule only moved when no later global rule of equal specificity could style the same element. The rule set is unchanged: all 927 rules are still present with identical declarations, checked rule by rule.src/test/features.ts). API tests for moved calls moved with them onto a shared fetch stand-in (src/test/fetchMock.ts). 2,821 tests, up from 2,808.no-unsafe-*errors.frontend/AGENTS.mddescribes the layout and rules, and the rootAGENTS.mdpoints to it.Verified
npm run lint,npm run format:check,tsc,vite buildnpm run test: 2,821 passednpm run check:removable: all 16 features removable🤖 Generated with Claude Code
Checked
dotnet build magic.slnpasses, which includes the analyzer rules, anddotnet test magic.slnpassescd frontend && npm run build && npm run testpasses, if the frontend changedbackend/files/config/appsettings.jsonis not part of the change