Skip to content

React migration phase 2: app shell, routing, theming, header/footer/settings, loader & error components - #867

Closed
vibhaseshadri-cognition wants to merge 3 commits into
devin/1791294942-react-phase1-data-layerfrom
devin/1791294931-react-phase2-shell
Closed

vibhaseshadri-cognition wants to merge 3 commits into
devin/1791294942-react-phase1-data-layerfrom
devin/1791294931-react-phase2-shell

Conversation

@vibhaseshadri-cognition

@vibhaseshadri-cognition vibhaseshadri-cognition commented Oct 6, 2026 •

Copy link
Copy Markdown

Summary

Phase 2 of the Angular → React migration (stacked on #866 → #865). Ports the Angular app shell into react/. Angular code is untouched.

Routing: same URLs as src/app/app.routes.ts plus the lazy modules' :id child routes:

<Route element={<AppLayout />}>                       // theme class wrapper + Header + <Outlet/> + Footer
  <Route index element={<Navigate to="/news/1" replace />} />
  {FEED_NAMES.map(f => <Route path={`${f}/:page`} element={<Feed key={f} feedType={f} />} />)}
  <Route path="item/:id" element={<ItemDetails />} />  // React.lazy, like Angular loadChildren
  <Route path="user/:id" element={<UserProfile />} />  // React.lazy
</Route>

As in Angular, /news, /item and /user with no param match nothing, and there is no catch-all route. feeds/Feed.tsx, item-details/ItemDetails.tsx and user/UserProfile.tsx are placeholders. Phases 3, 4 and 5 replace their bodies and keep the default exports, props and root data-testid attributes.

Shell components (core/Header, core/Footer, core/SettingsDialog, shared/components/Loader, shared/components/ErrorMessage): same markup, class names and copy as the Angular templates, wired to useSettings() from Phase 1. Behaviour differences:

  • Header links use NavLink (active class, same as routerLinkActive) and call window.scrollTo(0, 0) on click.
  • The settings cog and the close "×" have role="button", are keyboard-focusable, and respond to Enter and Space.
  • Font size and list spacing inputs save on onChange; Angular saved on keyup, which missed changes from the spinner arrows.
  • usePageViews copies Angular's NavigationEnd handler: when window.ga exists it sends ga('set','page',url) and then ga('send','pageview'). It skips / because that URL immediately redirects. The GA snippet itself is not added here; it moves to index.html in the PWA phase.
  • index.html gets the Angular boot loader (#root:empty + .app-loader), the skip link and the noscript message.
  • New shared/components/SafeHtml (DOMPurify.sanitize) replaces Angular's sanitized [innerHTML] binding. It's added here so Phases 4 and 5 (comments, poll options, user bios) share one implementation.

Styles: styles/_themes.scss, _theme_variables.scss and _media.scss are copied from Angular, with @import changed to @use, / division to math.div and darken() to color.adjust. Without Angular's view encapsulation, each component's SCSS is global, so element selectors are nested under the component's root class or id (e.g. #header h1, .overlay .popup). Vite uses the modern-compiler Sass API, so there are no legacy-API deprecation warnings.

Tests

  • Unit (Vitest + RTL), 100% coverage on the new code: route resolution for every feed, the redirect, lazy item and user routes, and unmatched paths; header links, active state and scroll-to-top; every settings control and its localStorage persistence; theme class switching; GA page views; loader, error message, footer and SafeHtml sanitization.
  • src/test/renderWithProviders.tsx wraps components in MemoryRouter + SettingsProvider, stubs matchMedia and adds a LocationProbe.
  • E2E (e2e/shell.spec.ts replaces the Phase 0 smoke test): the redirect, deep links for every feed, header navigation with the active link, the item and user routes, switching themes in the settings dialog (checks the computed header colour for each theme and that the choice survives a reload), and defaulting to night when the browser emulates prefers-color-scheme: dark.
  • The routing tests stub the HN API (fetch never resolves in unit tests; requests are aborted in e2e). That keeps them about the shell, so Phases 3–5 can add real data fetching without editing these tests.

Other changes:

  • tsconfig.node.json adds the DOM lib so page.evaluate callbacks typecheck.
  • ESLint turns off react-refresh/only-export-components for test helpers.
  • New dependencies: react-router-dom@6, dompurify@3, sass (dev).

Local (react/): format:check, lint, typecheck, test (76 tests passed, 100% coverage), build, e2e (10 passed).

Devin-Org: engineering

Link to Devin session: https://app.devin.ai/sessions/89cdada34e094c0b8a61fae52bf25e08
Open in Devin Desktop: https://app.devin.ai/desktop/session/89cdada34e094c0b8a61fae52bf25e08?variant=devin
Requested by: @vibhaseshadri-cognition

…oader and error components (migration phase 2)

Co-Authored-By: Vibha  Seshadri <vibha.seshadri@cognition.ai>
@devin-ai-integration

Copy link
Copy Markdown

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

…m the HN API (migration phase 2)

Co-Authored-By: Vibha  Seshadri <vibha.seshadri@cognition.ai>
devin-ai-integration[bot]

This comment was marked as resolved.

…rap focus in settings dialog (migration phase 2)

Co-Authored-By: Vibha  Seshadri <vibha.seshadri@cognition.ai>
@devin-ai-integration

Copy link
Copy Markdown

Closing as part of the nightly demo-repo reset — reopen if this demo artifact is still needed.

@devin-ai-integration
devin-ai-integration Bot deleted the devin/1791294931-react-phase2-shell branch October 26, 2026 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant