[codex] Improve UI architecture guardrails#623
Conversation
✅ Deploy Preview for matrixhub-ai canceled.
|
|
Hi @linghaoSu, DetailsInstructions for interacting with me using comments are available here. |
There was a problem hiding this comment.
Pull request overview
This PR strengthens the UI’s architectural boundaries by centralizing query/mutation option factories (including notification metadata), moving feature-specific UI out of shared, adding ESLint guardrails to prevent regressions, and improving UX/build output via form blur handling, locale coverage, and Vite chunk splitting.
Changes:
- Centralized query/mutation definitions (incl. notification metadata) and migrated call sites to use
*QueryOptions()/*MutationOptions(). - Added ESLint rules to enforce shared↔features boundaries, forbid component-owned notifications, and discourage inline query keys / direct MRT usage.
- Improved UX/build output: added missing TanStack Form blur handlers, filled missing i18n keys, and split major vendor chunks in Vite.
Reviewed changes
Copilot reviewed 33 out of 34 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| ui/vite.config.ts | Adds Rollup manualChunks to split large vendor bundles. |
| ui/src/types/tanstack-query.ts | Extends notification meta typing to support resolver-based success message/color. |
| ui/src/routes/(auth)/route.tsx | Switches logout to centralized mutation options. |
| ui/src/routes/(auth)/(app)/projects/index.tsx | Uses prefetchQuery for route-level prefetching. |
| ui/src/queryClient.ts | Adds resolver support for mutation success notifications and colors. |
| ui/src/locales/zh/projects.json | Adds missing member-mutation notification strings. |
| ui/src/locales/zh/profile.json | Adds missing error notification strings for profile actions. |
| ui/src/locales/zh/login.json | Adds missing login/logout error strings. |
| ui/src/locales/en/projects.json | Adds missing member-mutation notification strings. |
| ui/src/locales/en/profile.json | Adds missing error notification strings for profile actions. |
| ui/src/locales/en/login.json | Adds missing login/logout error strings. |
| ui/src/features/projects/pages/ProjectModelsPage.tsx | Uses feature-owned ModelCard to avoid shared→features dependency. |
| ui/src/features/projects/members/members.mutation.ts | Centralizes member mutation meta error messages + invalidations. |
| ui/src/features/projects/members/components/EditRoleModal.tsx | Adds missing blur handler for TanStack Form field. |
| ui/src/features/projects/members/components/AddMemberModal.tsx | Reuses allUsersQueryOptions() and adds missing blur handlers. |
| ui/src/features/projects/components/CreateProjectModal.tsx | Reuses allRegistriesQueryOptions() and adds missing blur handlers. |
| ui/src/features/profile/profile.mutation.ts | Centralizes profile mutation option factories + notifications. |
| ui/src/features/profile/pages/SecurityPage.tsx | Reuses centralized reset-password mutation + improves field validation UX. |
| ui/src/features/profile/pages/AccessTokenPage.tsx | Reuses centralized create-token mutation + adds blur handling. |
| ui/src/features/profile/components/ExpireAtField.tsx | Plumbs optional blur handler through the custom field component. |
| ui/src/features/profile/components/CreateSshKeyModal.tsx | Wires blur handling to ExpireAtField. |
| ui/src/features/profile/components/AccessTokenTable.tsx | Reuses centralized delete-token mutation and fixes delete variable handling. |
| ui/src/features/models/components/ModelCard.tsx | Introduces feature-owned ModelCard component. |
| ui/src/features/models/components/HotModelList.tsx | Updates to import ModelCard from features. |
| ui/src/features/models/components/AllModelList.tsx | Updates to import ModelCard from features. |
| ui/src/features/login/pages/LoginPage.tsx | Reuses centralized login mutation + adds blur handling. |
| ui/src/features/login/login.mutation.ts | Adds centralized login/logout mutation option factories with notification meta. |
| ui/src/features/admin/users/users.query.ts | Adds allUsersQueryOptions() + corresponding key. |
| ui/src/features/admin/users/users.mutation.ts | Adds typed batch-delete result + resolver-based success notification meta. |
| ui/src/features/admin/users/components/BatchDeleteUsersModal.tsx | Removes component-owned notifications in favor of mutation meta. |
| ui/src/features/admin/replications/components/ReplicationFormModal.tsx | Reuses allRegistriesQueryOptions() for dropdown data. |
| ui/src/features/admin/registries/registries.query.ts | Adds allRegistriesQueryOptions() + corresponding key. |
| ui/eslint.config.js | Adds architectural guardrails (restricted imports, queryKey syntax restriction). |
| ui/agents/patterns.md | Updates docs to describe resolver-based success message/color behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| { | ||
| patterns: [ | ||
| { | ||
| group: ['@/features/*'], |
| function resolveNotificationMetaValue( | ||
| value: string | ((data: unknown, variables: unknown, context: unknown) => string | undefined) | undefined, | ||
| data: unknown, | ||
| variables: unknown, | ||
| context: unknown, | ||
| ) { | ||
| return typeof value === 'function' | ||
| ? value(data, variables, context) | ||
| : value | ||
| } |
Summary
ModelCardout ofsharedto remove theshared -> featuresdependencyWhy
The UI layer had several repeated patterns that were easy to regress: feature imports from shared components, component-owned notifications, inline query keys, and direct table imports outside the shared table wrapper. This PR codifies those expectations and moves more behavior into feature-level query and mutation factories.
Validation
pnpm lintpnpm typecheckpnpm buildgit diff --check