Skip to content

Rewrite Angular 9 HN PWA as React 18 + TypeScript + Vite (react-app/) - #945

Open
devin-ai-integration[bot] wants to merge 2 commits into
masterfrom
devin/1794513101-react18-vite-rewrite
Open

devin-ai-integration[bot] wants to merge 2 commits into
masterfrom
devin/1794513101-react18-vite-rewrite

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Summary

Full port of the Angular 9 client into react-app/ (React 18, TS strict, Vite 6, React Router 6, TanStack Query 5, vite-plugin-pwa, Vitest/RTL, Playwright). Deploy is pointed at the new build; the Angular src/ is left untouched for side-by-side comparison until cutover.

Note: earlier React-migration PRs exist on this repo (e.g. #944, #943). This is a fresh implementation of the same request; only one should land.

Route map (parity with src/app/app.routes.ts)

'/'            -> <Navigate to="/news/1" />
'/{news,newest,show,ask,jobs}' children [':page' -> <Feed feedType=... />]   // feed type via route config
'/item/:id'    -> lazy(() => import('./item-details/ItemDetails'))
'/user/:id'    -> lazy(() => import('./user/User'))

Data layer – HackerNewsAPIService (RxJS) → src/api/hackernews.ts fetch functions + useFeed/useItem/useUser hooks. Poll options are still fetched from story.id + i + 1 and summed into poll_votes_count. fetchUser falls back to https://api.hnpwa.com/v0/user/<id>.json because node-hnapi /user/:id currently 404s. Queries use networkMode: 'always' so the service worker can answer offline (TanStack's default would pause and spin forever).

Settings/theme – SettingsService → SettingsProvider + useLocalStorage (same keys: theme, openLinkInNewTab, titleFontSize, listSpacing; same prefers-color-scheme fallback). Theme class (default|night|amoledblack) goes on <html>. Angular SCSS was copied and nested under .app-* host classes to emulate view encapsulation; global styles are imported before components so the cascade matches Angular.

PWA (ngsw-config.json parity) – app shell (index.html, JS/CSS, favicon, manifest) precached; /assets/** + fonts/images StaleWhileRevalidate; node-hnapi/HNPWA NetworkFirst (5s timeout, 300 entries, 7d). public/ngsw-worker.js is a kill switch that unregisters the old Angular worker and deletes ngsw:* caches for existing installs. Note: the Workbox urlPattern callback is serialized into sw.js, so it must not close over module variables (a regex is used).

CI/hosting – .travis.yml: Node 22/npm 11, cd react-app → lint, typecheck, unit, build, e2e, then firebase deploy --only hosting. firebase.json public: react-app/dist, no-cache on sw.js/ngsw-worker.js, immutable hashed assets.

Verification

  • npm run lint, npm run typecheck, npm run build clean
  • Vitest/RTL: 32 tests (comment pipe, API incl. poll + user fallback, settings/theme, all routes, pagination, recursive comment collapse, settings popup)
  • Playwright: 11 tests – every route + pagination, nav, lazy chunk loading, theme persistence, and an offline test (SW installed → network off → visited feed/item served from cache, unvisited feed shows the offline error inside the app shell)
  • Lighthouse 11 (mobile) on /news/1, React preview vs live Angular (angular2-hn.firebaseapp.com):
Perf A11y Best Pr. SEO PWA
Angular 92 92 100 88 88
React 100 94 100 88 88

Both miss only maskable-icon in PWA (same manifest icons reused).

Link to Devin session: https://devin-gtm.devinenterprise.com/sessions/3c3c9bc973664afc9e1aa2739618e56e
Open in Devin Desktop: https://devin-gtm.devinenterprise.com/desktop/session/3c3c9bc973664afc9e1aa2739618e56e?variant=devin
Requested by: @piyushpuri96


Note

Devin errored when opening this Pull Request as piyushpuri96.
As a fallback, Devin opened this PR as itself.


🟢 Devin Review found nothing to fix · View findings · Follow Devin's work

Devin Review

- react-app/: React Router route map matching app.routes.ts, React.lazy item/user routes
- fetch API + TanStack Query hooks (no RxJS), HNPWA user fallback
- settings context + localStorage hook, root theme class, reused SCSS
- vite-plugin-pwa with app-shell precache and HN API runtime cache
- Vitest/RTL unit tests and Playwright e2e (incl. offline)
- Travis builds/tests react-app; Firebase serves react-app/dist

Co-Authored-By: piyush@cognition.ai <piyush.b.puri@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Author

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

@socket-security

socket-security Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Warning

Review the following alerts detected in dependencies.

According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.

Priority Alert  (click "▶" to expand/collapse) Action
Low priority
Critical CVE: Tinypool: Prototype Pollution gadget in worker options leads to Remote Code Execution

CVE: GHSA-5gmw-xhrv-c9v3 Tinypool: Prototype Pollution gadget in worker options leads to Remote Code Execution (CRITICAL)

Affected versions: < 2.1.1

Patched version: 2.1.1

From: react-app/package-lock.json → npm/vitest@3.2.7 → npm/tinypool@1.1.1

ℹ Read more on: This package | This alert | What is a critical CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known critical CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/tinypool@1.1.1. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn
Low priority
Critical CVE: Tinypool: Prototype Pollution Gadget to RCE in run() options

CVE: GHSA-85c8-ppgw-ccpr Tinypool: Prototype Pollution Gadget to RCE in run() options (CRITICAL)

Affected versions: < 2.1.2

Patched version: 2.1.2

From: react-app/package-lock.json → npm/vitest@3.2.7 → npm/tinypool@1.1.1

ℹ Read more on: This package | This alert | What is a critical CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known critical CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/tinypool@1.1.1. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn

View full report

@devin-ai-integration

Copy link
Copy Markdown
Author

Production-preview UI QA against the live Angular app (https://angular2-hn.firebaseapp.com), using live HN data.

Passed: / → /news/1; all five feed routes and nav active states; page 2 starts at 31; Prev/More; jobs header; recursive comments with collapse/expand; user profiles (via the HNPWA fallback); settings (new tab, font size, list spacing); Default/Night/Black themes match Angular and persist; 375px mobile layout and back buttons; poll /item/126809 matches Angular (3 choices, 73 / 49 / 179 points).

Offline (React): this ran in an isolated browser with the network actually off. Cached /news/1 (30 stories) and an item page (60 comments) still reload. Uncached /show/1 keeps the app shell and shows "Could not load show stories."

Not verified: Angular-original offline parity. The live Angular deployment exposed no service-worker registration in a fresh browser, so there was no baseline to compare against. Lighthouse (React 88 PWA = Angular 88) is in the PR description.

QA recording

Cached feed offline Uncached feed offline
offline feed offline error
Angular vs React visual comparison
Angular React
Angular default React default
Angular night React night
Angular black React black
Angular mobile React mobile
Angular poll React poll

Written by Devin

Co-Authored-By: piyush@cognition.ai <piyush.b.puri@gmail.com>

@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 found 1 finding. Devin automatically fixed it.

Fixed by Devin (1)
  • Missing profiles stuck loading forever — Confirmed api.hnpwa.com returns HTTP 200 null for unknown users. fetchUser now throws on a null body, so /user/ shows 'Could not load user'. Covered by a unit test and checked against the live API in the preview build.

View findings in Devin Review · Follow Devin's work

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.

0 participants