Repository navigation
refactor(renderer): codify module boundaries and decompose notification state - #3410
Merged
Merged
Conversation
…on state Make the renderer's architecture explicit and enforced, then split the single notification hook into focused modules. - Add ARCHITECTURE.md documenting the one-way layer direction, state ownership per kind, and the single-host side-effect pattern; point to it from CONTRIBUTING.md - Enforce the layer direction with oxlint no-restricted-imports overrides, treating `utils` and `stores` as peer domain layers - Move all icon components into a leaf `src/renderer/icons/` so lower layers can import them without an exception - Fix the non-reactive `hasMultipleAccounts` selector in AppearanceSettings - Add pure `utils/notifications/status.ts` derivation and consume it from the route and the hook - Split `useNotifications` into query / mutations / effects / host hooks and remove the `withSideEffects` flag; the public reader API is unchanged Verified with tsc, oxlint/format checks, and the full test suite.
There was a problem hiding this comment.
🟡 Changes recommended
The icons boundary enforcement gap remains unresolved, along with two review nits.
1 open finding
What changed in this PR
Refactors renderer module boundaries and decomposes notification state management while preserving the public notification API.
Changes:
- Adds architecture documentation and lint boundary rules.
- Moves icons into a dedicated renderer layer.
- Splits notification querying, mutations, effects, and hosting.
- Extracts notification status helpers and fixes reactive account selection.
Review notes:
- Moderate:
vite.config.mtsdoes not enforce boundaries forsrc/renderer/icons/**. - Nit:
ARCHITECTURE.mdconflicts with existing type-only dependencies. - Nit:
AppearanceSettingschanges visible checkbox behavior, conflicting with the no-behavior-change description.
| File | Reviewed change |
|---|---|
vite.config.mts |
Adds renderer boundary lint rules. |
src/renderer/utils/ui/icons.ts |
Updates icon imports. |
src/renderer/utils/notifications/status.ts |
Adds notification status derivation. |
src/renderer/utils/notifications/status.test.ts |
Tests status helpers. |
src/renderer/utils/forges/gitlab/adapter.ts |
Updates GitLab icon usage. |
src/renderer/utils/forges/gitlab/adapter.test.ts |
Updates GitLab icon imports. |
src/renderer/utils/forges/bitbucket/adapter.ts |
Updates Bitbucket icon usage. |
src/renderer/utils/forges/bitbucket/adapter.test.ts |
Updates Bitbucket icon imports. |
src/renderer/routes/Notifications.tsx |
Uses shared notification status logic. |
src/renderer/routes/Login.tsx |
Updates logo import. |
src/renderer/routes/AccountScopes.tsx |
Updates scope icon import. |
src/renderer/icons/VolumeUpIcon.tsx |
Relocates volume-up icon. |
src/renderer/icons/VolumeDownIcon.tsx |
Relocates volume-down icon. |
src/renderer/icons/ScopeStatusIcon.tsx |
Relocates scope status icon. |
src/renderer/icons/ScopeStatusIcon.test.tsx |
Updates scope icon tests. |
src/renderer/icons/LogoIcon.tsx |
Relocates logo icon. |
src/renderer/icons/LogoIcon.test.tsx |
Updates logo icon tests. |
src/renderer/icons/GitLabIcon.tsx |
Adds GitLab leaf icon. |
src/renderer/icons/BitbucketIcon.tsx |
Adds Bitbucket leaf icon. |
src/renderer/icons/__snapshots__/ScopeStatusIcon.test.tsx.snap |
Updates snapshots. |
src/renderer/icons/__snapshots__/LogoIcon.test.tsx.snap |
Updates snapshots. |
src/renderer/hooks/useNotifications.ts |
Exposes the composed notification API. |
src/renderer/hooks/useNotifications.test.tsx |
Updates notification hook tests. |
src/renderer/hooks/notifications/useNotificationsQuery.ts |
Handles notification queries. |
src/renderer/hooks/notifications/useNotificationsHost.ts |
Owns the notification host. |
src/renderer/hooks/notifications/useNotificationMutations.ts |
Handles notification mutations. |
src/renderer/hooks/notifications/useNotificationEffects.ts |
Handles notification side effects. |
src/renderer/components/Sidebar.tsx |
Updates logo import. |
src/renderer/components/settings/SystemSettings.tsx |
Updates volume icon imports. |
src/renderer/components/settings/AppearanceSettings.tsx |
Fixes reactive account selection. |
src/renderer/components/settings/AppearanceSettings.test.tsx |
Covers account selection behavior. |
src/renderer/components/GlobalEffects.tsx |
Mounts the notification host. |
src/renderer/__helpers__/vitest.setup.ts |
Mocks the notification host. |
CONTRIBUTING.md |
Links architecture guidance. |
ARCHITECTURE.md |
Documents renderer architecture and dependencies. |
🧠 Review effort: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: setchy <386277+setchy@users.noreply.github.com>
Complete the boundary rule for the leaf layers introduced with the architecture documentation. - Add no-restricted-imports overrides so `icons` may not import any implementation layer, and `types`/`constants` may not import implementation layers (type-only imports allowed) - Drop the dead `**/context/**` group from the sortImports config, since AppContext is retired Verified with tsc, oxlint/format checks, and the full test suite.
State the layer rule as "runtime imports are one-way; type-only imports are exempt" and list types/constants/icons together as the leaf modules, so the diagram no longer contradicts types.ts's type-only imports.
|
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.




Summary
Two related pieces of renderer cleanup, both included in this PR — nothing is deferred to a follow-up.
Behaviour-preserving, with one deliberate exception: a stale-UI fix in
AppearanceSettings(called out below).1. Architecture — documented and enforced
ARCHITECTURE.md: the one-way layer direction (runtime imports are one-way; type-only imports are exempt), state ownership per kind, the single-host side-effect pattern, and the forge adapter seam. Linked fromCONTRIBUTING.md.no-restricted-importsoverrides invite.config.mts(scoped to source files).utilsandstoresare treated as peer domain layers, since they reference each other today. The leaf layers are enforced too:iconscannot import any implementation layer, andtypes/constantscannot either (type-only imports are allowed, matching the doc).src/renderer/icons/, so lower layers can import them with no lint exception.hasMultipleAccountsselector inAppearanceSettings: it selected the accessor instead of invoking it, so the account-header checkbox could stay stale when the account count changed. It now updates reactively, with a regression test. This is the one user-visible behaviour change in the PR.2. Notification state — decomposed
utils/notifications/status.ts(deriveStatus,deriveGlobalError,hasNoAccountErrors), consumed by both the route and the hook.useNotificationsintohooks/notifications/:useNotificationsQuery— read side (optional polling observer)useNotificationMutations— mark-as-read / done / unsubscribeuseNotificationEffects— sound/native alerts, wake/focus refetch, failure pruninguseNotificationsHost— owns the polling observer plus the effects; mounted once fromGlobalEffectswithSideEffectsflag; side-effect ownership is now structural. The publicuseNotifications()reader/action API is unchanged.Notes for reviewers
utils↔storescoupling is documented as a deliberate peer relationship rather than forced into a strict order; breaking that coupling is a separate refactor.useNotificationsHost(mirroring the existinguseNotificationsmock);useNotifications.test.tsxopts back into the real host viavi.unmock.Verification
tsc --noEmit— cleanpnpm check(format + lint) — cleanpnpm test— 187 files, 1899 tests passingOut of scope (separate changes, not in this PR)
Captured as their own OpenSpec changes, not part of this PR:
hooks/intostores/.buildAccountItems,buildRepositoryItems) out ofNotificationList.tsx.