Skip to content

Phase 1: React 18 + Vite + TypeScript scaffold and shared infrastructure - #570

Open
vibhaseshadri-cognition wants to merge 3 commits into
masterfrom
devin/1785951605-react-phase1-scaffold
Open

Phase 1: React 18 + Vite + TypeScript scaffold and shared infrastructure#570
vibhaseshadri-cognition wants to merge 3 commits into
masterfrom
devin/1785951605-react-phase1-scaffold

Conversation

@vibhaseshadri-cognition

@vibhaseshadri-cognition vibhaseshadri-cognition commented Aug 6, 2026

Copy link
Copy Markdown

Summary

First phase of the Angular → React migration. Adds a self-contained React app under web/ (Angular in src/ is untouched and still builds) plus a GitHub Actions workflow running lint, test, build for web/. Later phases port the feature components on top of this shared infrastructure and only then delete the Angular source.

What landed:

  • Stack: React 18 + TS, Vite 5, Vitest + React Testing Library (jsdom), ESLint 9 flat config + Prettier reusing the Angular repo's prettier settings (tabWidth: 4, singleQuote, printWidth: 120, trailingComma: es5).

  • Models (src/models/) ported from src/app/shared/models/ as interfaces; fields the API omits (url, domain, poll, about, …) are optional so strict mode is usable.

  • api/hackerNews.ts replaces HackerNewsAPIService — Observables become promises over native fetch, base URL unchanged. Poll aggregation is preserved but now awaits all options instead of firing detached subscriptions:

    const story = await lazyFetch<Story>(`${BASE_URL}/item/${id}`);
    if (story.type === 'poll' && story.poll) {
        const options = await Promise.all(story.poll.map((_, i) => fetchPollContent(story.id + i + 1)));
        story.poll = options;
        story.poll_votes_count = options.reduce((votes, o) => votes + o.points, 0);
    }

    lazyFetch additionally rejects on non-2xx so components can render the error state instead of parsing an error body.

  • context/SettingsContext.tsx replaces the SettingsService singleton: same localStorage keys (theme, titleFontSize, listSpacing, openLinkInNewTab) and the same prefers-color-scheme behaviour — subscribe to the media query, and on start-up fall back to night/default from the query only when no theme was saved.

  • utils/formatCommentCount.ts replaces the comment pipe; components/Loader / ErrorMessage port the shared components with their SCSS.

  • Styles: _media, _theme_variables, _themes copied over ($x / nmath.div so the build is warning-free); the three themes apply through the App wrapper div driven by settings.theme.

27 tests pass; npm run lint and npm run build are clean.

Note: this PR targets COG-GTM/angular2-hn because pushing to ankehao-demo/angular2-hn returns 403 (no write access); both repos are at the same commit.

Link to Devin session: https://app.devin.ai/sessions/6382e57ba3ff4a388ee6e9bd0ad2d37d
Requested by: @vibhaseshadri-cognition


Devin Review

Status Commit
⚪ Not started

Run Devin Review

💡 Connect your GitHub account to enable automatic code reviews.

Open in Devin Review (Staging)

Ports models, HackerNews API module, SettingsContext, comment count util, Loader/ErrorMessage and SCSS themes; adds Vitest + RTL, ESLint/Prettier and a GitHub Actions CI workflow.
@devin-ai-integration

Copy link
Copy Markdown

🤖 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

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