OpenHands/agent-canvas

Consolidate the duplicate src/context/ and src/contexts/ directories

Open

#1,540 opened on Jun 29, 2026

View on GitHub
 (3 comments) (0 reactions) (0 assignees)TypeScript (26 forks)github user discovery
enhancementgood first issue

Repository metrics

Stars
 (43 stars)
PR merge metrics
 (PR metrics pending)

Description

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:

  • NavigationContext is the seam that keeps components decoupled from react-router — important for the library/embedded use case and for tests. Folding it into a Zustand store would be worse than relocating it.
  • ScrollContext is scoped to the chat DOM/provider tree and fits React context better than a global store.

Proposed approach

  1. Move navigation-context.tsx and scroll-context.tsx into src/contexts/ as-is (no behavior change, not folded into stores).
  2. Update imports across src, tests, and test-utils.tsx.
  3. Remove src/context/ completely. (No re-export compat shim — pre-1.0, we don't keep compat shims.)
  4. Optionally add a small lint/import guard or architecture test so #/context/ can't come back.

Acceptance criteria

  • src/context/ removed; all contexts live under src/contexts/ (relocated as-is, not folded into stores)
  • git grep -n "#/context/" src returns nothing
  • npm run typecheck and 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.

Contributor guide