[Feature]: Consolidate duplicate src/context/ and src/contexts/ directories
Problem or Motivation
The codebase has both a singular src/context/ (navigation-context.tsx, scroll-context.tsx) and a plural src/contexts/ (active-backend-context.tsx, conversation-websocket-context.tsx, etc.). They hold the same kind of module, causing confusion about where contexts live and inconsistent import paths across files (following up on #15532).
Desired Behavior
All React context modules should live under src/contexts/. The legacy src/context/ directory should be removed, and all imports should reference #/contexts/... without changing existing runtime behavior. An ESLint import restriction should prevent #/context/* from returning.
Acceptance Criteria
- All React context modules reside in
src/contexts/as-is;src/context/is completely removed. - No
#/context/imports remain in the codebase (git grep -n "#/context/"returns zero matches). - References in documentation and test-mapping are updated to
src/contexts/. - ESLint config contains a
no-restricted-importsrule for#/context/*. - TypeScript check and test suites pass cleanly.
- A screenshot/video showing the clean check verification and application boot is provided with the PR.
OpenHands AI triage
The following comments and acceptance criteria were added by the OpenHands AI agent.
Triage
Scope is a pure relocation with no behavior change: move src/context/navigation-context.tsx and src/context/scroll-context.tsx into src/contexts/ as-is, update every import, remove src/context/, add an ESLint guard against #/context/*, and refresh the two non-code references. The design questions raised in #15532 are already resolved in that thread and reflected in this body: both modules stay React contexts (no Zustand store folding), and there is no backwards-compatibility re-export shim.
Evidence from the current main tree: src/context/ holds exactly the two files above; src/contexts/ holds active-backend-context.tsx, conversation-websocket-context.tsx, settings-section-header-context.tsx, and websocket-provider-wrapper.tsx. #/context/ is imported in 43 files under src/, 42 under __tests__/, and in test-utils.tsx. Non-code references are tests/e2e/mock-llm/test-mapping.json (runAllSources entry src/context/**) and .agents/skills/frontend-development/references/guide.md (mentions src/context/navigation-context.tsx). eslint.config.js already uses no-restricted-imports with a paths entry, so the new guard belongs in that same rule.
Explicit non-goals: folding NavigationContext or ScrollContext into a global store; keeping a #/context/* re-export shim; any change to provider nesting, context values, or runtime behavior.
Acceptance Criteria
-
src/context/navigation-context.tsxandsrc/context/scroll-context.tsxare relocated tosrc/contexts/without changing their exported symbols or implementation, and thesrc/context/directory no longer exists in the working tree. - Every module that previously imported
#/context/navigation-contextor#/context/scroll-context(files undersrc/,__tests__/, andtest-utils.tsx) now imports from#/contexts/..., andgit grep -n "#/context/"run at the repository root returns zero matches. -
eslint.config.jscontains ano-restricted-importsentry that makes an import from#/context/*an error (verified by running eslint against a temporary file containing such an import, or by a committed test that asserts the restriction). -
tests/e2e/mock-llm/test-mapping.jsonrunAllSourcesreferencessrc/contexts/**instead ofsrc/context/**, and.agents/skills/frontend-development/references/guide.mdreferencessrc/contexts/navigation-context.tsx. -
npm run typecheckcompletes without errors andnpm testpasses. - No user-visible behavior changes: the app boots with
npm run dev, and navigation and chat scroll behavior are unchanged, demonstrated with a screenshot or video attached to the PR. - No
src/context/compatibility re-export shim is left behind.
Source: OpenHands/OpenHands