Skip to content

feat(react): port item details page with recursive collapsible comments - #935

Open
eashansinha wants to merge 6 commits into
react-migration/1794416868-trunkfrom
devin/1794418013-react-item-details
Open

eashansinha wants to merge 6 commits into
react-migration/1794416868-trunkfrom
devin/1794418013-react-item-details

Conversation

@eashansinha

@eashansinha eashansinha commented Nov 11, 2026 •

Copy link
Copy Markdown

Summary

Phase 2 slice (Item Details) of the Angular → React migration. Builds on #932 (devin/1794416940-react-foundation); diff shrinks to this slice once #932 merges.

  • ItemDetailsPage (/item/:id) replaces the placeholder: loading/error states via shared Loader/ErrorMessage, mobile + laptop headers, job vs story meta, poll results with pollBar widths (points / poll_votes_count), story text, and top-level comment list. Comment count uses the existing formatCommentCount (Angular comment pipe equivalent). Title link respects settings.openLinkInNewTab.
  • item-details/Comment.tsx: recursive comment with [-]/[+] collapse hiding the body and children; deleted comments render as in Angular.
  • ItemDetails.scss / Comment.scss: ported from the Angular component SCSS, same class names.
  • sanitizeHtml.ts: HN HTML is rendered via dangerouslySetInnerHTML, so it's passed through an allowlist sanitizer first (Angular's [innerHTML] sanitized implicitly). Strips scripts/unknown attrs and neutralizes javascript:/data: URLs.
  • Fetch uses AbortController so fast route changes don't render stale items.

Outside the slice: removed the /item/123 → "Item: 123" placeholder case from react-app/src/routes.test.tsx (it asserted the placeholder this PR replaces). Story lacks content/text, so the page extends it locally rather than editing shared models.

Verification

  • npm run lint, npm test (32 passed, 9 new for this slice), npm run build all pass in react-app/.
  • Dev server against live HN API: story 8863 and poll 126809 at desktop and mobile widths; collapse/expand confirmed.

Story
Collapsed
Poll
Mobile

Not verified: side-by-side with the running Angular app (root Angular deps aren't installed on this VM); styles are ported from the original SCSS.

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


Devin Review (Staging)

devin-ai-integration Bot and others added 4 commits November 11, 2026 17:12
Co-Authored-By: Eashan Sinha <eashan.sinha@cognition.ai>
Co-Authored-By: Eashan Sinha <eashan.sinha@cognition.ai>
Co-Authored-By: Eashan Sinha <eashan.sinha@cognition.ai>
Co-Authored-By: Eashan Sinha <eashan.sinha@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

Original prompt from Devin Bot

Repo: COG-GTM/angular2-hn (Angular 9 Hacker News PWA). The user asked: "let's spin up multiple devins to execute on an angular to react migration in @COG-GTM/angular2-hn". This is Phase 2 of a multi-session migration: four sessions run in parallel, each porting one slice into the React app in react-app/.

The Phase 1 foundation is PR #932 (#932, branch devin/1794416940-react-foundation); it may not be merged yet. Branch from devin/1794416940-react-foundation and open your PR against react-migration/1794416868-trunk (NOT master); once #932 merges, your diff shrinks to your slice. Read react-app/README.md for the models, API client (react-app/src/api/hackerNewsApi.ts), settings context (useSettings), shared Loader/ErrorMessage, routes and placeholder components you build on.

Rules: only replace/add files for your slice (plus its tests); don't change the shared foundation files (models, api, settings, routes, styles) except a minimal, clearly explained addition if truly required, since other sessions edit in parallel. Match the Angular behavior, markup classes and SCSS of the original components so the look is unchanged. Add Vitest + React Testing Library tests for your slice; npm run lint, npm test and npm run build in react-app/ must pass and CI must be green. Run the dev server and check your pages in the browser against the Angular original. Final message: PR URL, what was verified, and any change you made outside your slice.

Your slice:
ITEM DETAILS. Port src/app/item-details/ (ItemDetailsComponent + recursive collapsible CommentComponent, including poll results, story text, loading/error states, and the comment pipe usage) into the ItemDetailsPage for /item/:id.

@socket-security

socket-security Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

@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.

Note

Newer findings are available below. Devin Review posted a newer report on this PR, in addition to the findings presented here.

Devin Review found 2 potential issues.

1 code quality issue is available in Devin Review only.

Devin Review (Staging)

Debug

Playground

Comment thread react-app/README.md
Comment on lines +31 to +32
Page and shell components are deliberately TODO placeholders; no API calls are wired to them yet.
Later owners should consume shared contracts rather than edit other owners' files.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔍 Migration map understates item page progress

The map still calls every page a placeholder without API calls. ItemDetailsPage now fetches items, so the ownership guidance is stale.

Devin Review (Staging)


Was this helpful? React with 👍 or 👎 to provide feedback.

Debug

Playground

Comment on lines +15 to +17
if (name === 'href' || name === 'src' || name === 'cite') {
const value = Array.from(attribute.value).filter(character => character.charCodeAt(0) > 32).join('');
if (/^(javascript|vbscript|data):/i.test(value)) node.setAttribute(name, `unsafe:${attribute.value}`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟨 Untrusted links can launch external apps

When a reader clicks an intent: link in a comment, sanitizeHtml leaves the scheme intact. On supported devices, the link can launch an installed app.

Devin Review (Staging)


Was this helpful? React with 👍 or 👎 to provide feedback.

Debug

Playground

devin-ai-integration Bot and others added 2 commits November 11, 2026 17:33
Co-Authored-By: Eashan Sinha <eashan.sinha@cognition.ai>
Co-Authored-By: Eashan Sinha <eashan.sinha@cognition.ai>

@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 1 new potential issue.

1 code quality issue is available in Devin Review only.

Devin Review (Staging)

Debug

Playground

@@ -0,0 +1,25 @@
const allowedTags = new Set('a abbr b blockquote br code dd del div dl dt em h1 h2 h3 h4 h5 h6 hr i img ins kbd li ol p pre q s small span strong sub sup table tbody td th thead tr u ul'.split(' '));
const allowedAttributes = new Set('alt class colspan height rowspan target title width'.split(' '));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔍 Comment links lose crawler hints

Links carrying rel="nofollow" or rel="ugc" lose those tokens, whether or not they have a target. Search crawlers can treat user-posted links differently; confirm whether this change is intended.

Devin Review (Staging)


Was this helpful? React with 👍 or 👎 to provide feedback.

Debug

Playground

@devin-ai-integration 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 2 findings. Devin automatically fixed all 2 findings.

Fixed by Devin (2)
  • Missing items crash the details page — Page validates the response and shows the error state for error objects/null/invalid comments.
  • Comment links can hijack the parent tab — rel is no longer user-controlled; targeted anchors get rel="noopener noreferrer".

View findings in Devin Review · Follow Devin's work

Devin Review

@devin-ai-integration

Copy link
Copy Markdown

Browser-tested HEAD 8176267 against the live HN API, compared with the deployed Angular original.

  • Passed: story meta + external title link, nested comments, collapse/restore of a subtree.
  • Passed: poll points and proportional bars (73/49/179 → 24.25%/16.28%/59.47%).
  • Passed: Ask story text, loading indicator, error state for an invalid id (crash found in testing, fixed in 8176267).
  • Passed: 390px mobile header/back button, comment-author link to /user/:id.
  • Not exercised live: malicious HTML / rel="noopener noreferrer" hardening (covered by unit tests). Shared header is still the foundation placeholder.

Flow recording

Expanded story Collapsed subtree
Story Collapsed
Poll results Invalid id
Poll Error
Angular — Ask React — Ask
Angular React

Written by Devin

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