Consolidate the duplicate src/context/ and src/contexts/ directories
#1540 aperta il 29 giu 2026
Metriche repository
- Star
- (43 star)
- Metriche merge PR
- (Metriche PR in attesa)
Descrizione
The codebase has both a singular src/context/ (navigation-context, scroll-context) and a plural src/contexts/ (active-backend-context, conversation-websocket-context, settings-section-header-context, websocket-provider-wrapper). They hold the same kind of module, so contributors can't predict where a context lives, and imports reference both inconsistently (~36 files use #/context/).
This is a pure move plus an import-path update — no behavior change.
Framing correction (per review)
Both navigation-context and scroll-context should be relocated as-is, not folded into stores:
NavigationContextis the seam that keeps components decoupled fromreact-router— important for the library/embedded use case and for tests. Folding it into a Zustand store would be worse than relocating it.ScrollContextis scoped to the chat DOM/provider tree and fits React context better than a global store.
Proposed approach
- Move
navigation-context.tsxandscroll-context.tsxintosrc/contexts/as-is (no behavior change, not folded into stores). - Update imports across
src, tests, andtest-utils.tsx. - Remove
src/context/completely. (No re-export compat shim — pre-1.0, we don't keep compat shims.) - Optionally add a small lint/import guard or architecture test so
#/context/can't come back.
Acceptance criteria
-
src/context/removed; all contexts live undersrc/contexts/(relocated as-is, not folded into stores) -
git grep -n "#/context/" srcreturns nothing -
npm run typecheckand the test suite stay green - App boots cleanly in
npm run dev
This issue was drafted by an AI agent on behalf of the user, and refined per review feedback in the discussion below.