feat: Migrate Angular to React (Vite + TypeScript)#5
Open
devin-ai-integration[bot] wants to merge 6 commits intomainfrom
Open
feat: Migrate Angular to React (Vite + TypeScript)#5devin-ai-integration[bot] wants to merge 6 commits intomainfrom
devin-ai-integration[bot] wants to merge 6 commits intomainfrom
Conversation
Complete rewrite of the RealWorld Conduit app from Angular to React: - Vite + React 18 + TypeScript + React Router v6 - Axios-based API client with interceptors (base URL, token, error handling) - Auth context with JWT persistence and exponential backoff retry - All pages: Home, Auth (login/register), Article, Editor, Settings, Profile - Shared components: ArticleList, ArticlePreview, FavoriteButton, FollowButton, ListErrors - Protected routes and guest-only routes - Markdown rendering with marked - Debug interface (window.__conduit_debug__) for E2E testing - Same port (4200) for backward compatibility with Playwright tests Co-Authored-By: shayan <shayan@cognition.ai>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
- Add DOMPurify to sanitize markdown HTML output (XSS prevention) - Add event-based auth purge on 401 to update React state - Add catch blocks to FavoriteButton and FollowButton for network errors - Add name attributes to all form inputs (Editor, Auth, Settings) - Add error handling for comment add/delete operations - Fix ProtectedRoute to return null for 'unavailable' auth state - Add empty feed message with link to Global Feed - Add 'Connecting...' text in header for unavailable state - Fix profile bio rendering for null values - Add .article-page/.profile-page/.user-info wrappers on error states Co-Authored-By: shayan <shayan@cognition.ai>
…th guard Co-Authored-By: shayan <shayan@cognition.ai>
- Remove nested .user-info div from Profile error states to fix Playwright strict mode violation (.profile-page, .user-info selector matched 2 elements) - Add defensive type checks in ArticleList for malformed JSON responses (prevents crash when response data is not valid article list format) Co-Authored-By: shayan <shayan@cognition.ai>
- Add cancelRetry() helper that clears pending retry timeouts - Call cancelRetry() in setAuth, purgeAuth, and handleAuthPurge - Add token existence checks before scheduling and executing retries - Update CLAUDE.md to reflect React + npm stack (was Angular + bun) Addresses Devin Review findings on retry timeout leaks and stale CLAUDE.md documentation. Co-Authored-By: shayan <shayan@cognition.ai>
… username - Profile: reset loadError and profile state when username param changes - Editor: verify current user is article author before populating form - Settings: navigate using server-returned username instead of local state - AuthContext: updateUser now returns the updated User object Addresses Devin Review round 3 findings. Co-Authored-By: shayan <shayan@cognition.ai>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Complete rewrite of the RealWorld "Conduit" app from Angular 21 to React 18 + Vite + TypeScript. All Angular source code, configuration (
angular.json,tsconfig.app.json,tsconfig.spec.json,vitest.config.ts,.browserslistrc), and unit tests are removed and replaced with a React equivalent.Stack: Vite 5, React 18, React Router v6, Axios, TypeScript, marked + DOMPurify
Architecture mapping:
HttpInterceptorFn(3 interceptors)src/services/api.ts)UserService+ RxJS observablesAuthContext+ React Context (src/context/AuthContext.tsx)JwtService(injectable)src/services/jwt.service.ts)requireAuthguardProtectedRoute/GuestRoutewrappers (src/App.tsx)useStateMarkdownPipemarked.parse()+ DOMPurify sanitizationwindow.__conduit_debug__The dev server runs on port 4200 (same as Angular) so the existing Playwright config continues to work without changes.
Updates since last revision
E2E test results: 137/138 passing (99.3%)
Fixes applied across multiple review rounds:
^3.x) to sanitizemarkedoutputauth:purgeevent on 401;AuthContextlistens to clear both token and user statesetAuth,purgeAuth, andhandleAuthPurgenow cancel pending retry timeouts viacancelRetry(), matching the Angular version'scancelRetry()+retryAttempt = 0pattern. Added two-layer token existence checks before scheduling and executing retries..user-infodiv from error states — Playwright's.profile-page, .user-infoselector was matching 2 elementsloadErrorandprofilestate are now reset whenusernameparam changes, preventing stale error/data when navigating between profilescurrentUser.username === article.author.usernamebefore populating the edit form; redirects non-authors to/, matching Angular'sEditorComponent.ngOnInitguardupdateUsernow returns the server-returnedUserobject; Settings navigates usingupdatedUser.usernameinstead of local form statenameattributes: All form inputs includenameattributes for E2E selector compatibilitywindow.__conduit_debug__exposesgetToken(),getAuthState(),getCurrentUser()bun run testcommand1 remaining failure —
should show error message on create article form when network fails(e2e/error-handling.spec.ts:617). Root cause: the test intercepts${API_BASE}/articles/(trailing slash) but the app POSTs to${API_BASE}/articles(no trailing slash). Playwright string route matching is exact, so the mock never fires. The contradictory test at line 63 (mockApiError(page, '/articles', ...)) passes because it uses the no-slash pattern.Review & Testing Checklist for Human
AuthContext.tsxreimplements exponential backoff (2s → 4s → 8s → 16s cap) usingsetTimeoutrecursion instead of RxJStimer/switchMap. ThecancelRetry()helper is called on login, logout, and 401 purge — but verify theuseCallbackdependency arrays are correct and that no stale closures exist. ThehandleAuthPurgelistener has[]deps but referencescancelRetry(stable ref, so this is fine — but worth confirming).currentUser.username !== article.author.usernameafter the article loads, butcurrentUsermay benullif auth is still in the "loading" state. The checkif (currentUser && ...)guards against this, but if the user navigates to/editor/:slugwith a valid token while auth is still loading, the form will populate without the ownership check untilcurrentUserresolves. Verify this is acceptable behavior.src/_redirectsfile (used by Netlify/Cloudflare for SPA routing) was deleted and not replaced. If deployed to a static host, deep-link navigation will 404.error-handling.spec.ts:617) is a test bug or an app bug.ArticlePage.tsxpipesmarked.parse()throughDOMPurify.sanitize()beforedangerouslySetInnerHTML. Confirm XSS security spec (26 tests) covers attack vectors you care about.Recommended test plan: Start the dev server (
npm start), then manually exercise these flows:/editor/<slug>— verify redirect to/<script>alert(1)</script>payload into an article body — verify it does not executeNotes
.spec.tsfiles) were removed with the Angular code and no React unit tests were added.realworld/git submodule (CSS theme + SVG assets) is still required — theindex.htmlloads styles from/realworld/assets/theme/styles.css.package.jsonswitched from Bun to npm as the package manager.CLAUDE.mdupdated to document the new React + npm commands.Link to Devin session: https://app.devin.ai/sessions/b8e83aefb43849ccb24bbf0d906406ba
Requested by: @shayanshafii