Skip to content

feature: Migrate Angular 9 HN PWA to React 18 + TypeScript (pixel-perfect, visual-regression verified)#321

Open
devin-ai-integration[bot] wants to merge 1 commit into
masterfrom
devin/1781110595-angular-to-react-migration
Open

feature: Migrate Angular 9 HN PWA to React 18 + TypeScript (pixel-perfect, visual-regression verified)#321
devin-ai-integration[bot] wants to merge 1 commit into
masterfrom
devin/1781110595-angular-to-react-migration

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Jun 10, 2026

Copy link
Copy Markdown

Summary

Full rewrite of the Angular 9 Hacker News PWA to React 18 + TypeScript + Vite, with pixel-perfect parity enforced by a Playwright visual-regression suite. Every Angular component, service, model, style and the PWA service worker were ported 1:1; the Angular/RxJS/zone.js/karma/protractor toolchain was removed.

Parity is not asserted by eye — Angular baseline screenshots were captured first (Phase 0), then the React output is diffed against them. 48/48 visual-regression tests pass within maxDiffPixelRatio: 0.01 (7 scenarios × 3 themes × 2 viewports + settings panel).

Architecture mapping

Angular React
HackerNewsAPIService (RxJS Observable + unfetch) src/hooks/useHackerNewsApi.ts — async fetch functions + generic useApiFetch<T> hook
SettingsService src/contexts/SettingsContext.tsxSettingsProvider / useSettings(), same localStorage keys + prefers-color-scheme listener
CommentPipe src/utils/formatComment.ts
*.component.ts/html/scss function components + co-located .scss
app.routes.ts (lazy modules) src/routes.tsx with React.lazy for item/user pages
Angular SW (ngsw-config.json) vite-plugin-pwa / Workbox (NetworkFirst for the HN API)

Notable porting detail (non-obvious)

Angular's ViewEncapsulation implicitly scopes component CSS. Flattening to global SCSS leaked rules across components and broke parity until fixed, e.g.:

  • header h1 { font-size: 16px } shrank the Settings popup title → render <Settings> outside <header>.
  • .item-details-view p { margin: 2px 0 } collapsed comment paragraph spacing → scoped to .laptop > p, .mobile > p so it doesn't reach dangerouslySetInnerHTML comment bodies.

Theme structural selectors (.wrapper, #header, .popup, .loader, …) are kept as literal global class names (not CSS modules) so the _themes.scss mixin selectors keep matching.

Testing

  • npm test — Vitest unit tests (17): formatComment, SettingsContext (persistence/theme/toggles), useHackerNewsApi (mocked fetch incl. poll sub-fetch tallying), Item rendering. All pass.
  • npm run test:vr — Playwright visual regression. 48/48 pass.
  • npm run lint, npm run typecheck, npm run build — all clean.

Screenshots

News (default) News (night)
news default news night
Item detail Settings panel
item settings

Link to Devin session: https://app.devin.ai/sessions/80307157bda94caa8de20724c3b44f4d
Requested by: @lburgers


Devin Review

Status Commit
🟢 Reviewed 9716d1d
Open in Devin Review (Staging)

…l regression parity

- Port all components, services, models, styles, routing and PWA setup from Angular to React 18 + Vite
- Replace RxJS services with React Context (SettingsContext) and async hooks (useHackerNewsApi)
- Add Playwright visual regression suite (48 tests: every view x 3 themes x mobile/desktop + settings) passing at maxDiffPixelRatio 0.01 vs Angular baseline
- Add Vitest unit tests for formatComment, SettingsContext, API functions and Item component
- Remove Angular/RxJS/zone.js/karma/protractor toolchain; update README and CI

Co-Authored-By: Lukas Burger <lukaskburger@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@staging-devin-ai-integration staging-devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 0 potential issues.

Open in Devin Review (Staging)
Debug

Playground

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

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