Repository navigation
feat(react): port item details page with recursive collapsible comments - #935
eashansinha wants to merge 6 commits into
Conversation
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>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
Original prompt from Devin Bot
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
| 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. |
There was a problem hiding this comment.
🔍 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.
Was this helpful? React with 👍 or 👎 to provide feedback.
Debug
| 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}`); |
There was a problem hiding this comment.
🟨 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.
Was this helpful? React with 👍 or 👎 to provide feedback.
Debug
Co-Authored-By: Eashan Sinha <eashan.sinha@cognition.ai>
Co-Authored-By: Eashan Sinha <eashan.sinha@cognition.ai>
| @@ -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(' ')); | |||
There was a problem hiding this comment.
🔍 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.
Was this helpful? React with 👍 or 👎 to provide feedback.
Debug
There was a problem hiding this comment.
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".
|
Browser-tested HEAD 8176267 against the live HN API, compared with the deployed Angular original.
|
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 sharedLoader/ErrorMessage, mobile + laptop headers, job vs story meta, poll results withpollBarwidths (points / poll_votes_count), story text, and top-level comment list. Comment count uses the existingformatCommentCount(Angularcommentpipe equivalent). Title link respectssettings.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 viadangerouslySetInnerHTML, so it's passed through an allowlist sanitizer first (Angular's[innerHTML]sanitized implicitly). Strips scripts/unknown attrs and neutralizesjavascript:/data:URLs.AbortControllerso fast route changes don't render stale items.Outside the slice: removed the
/item/123 → "Item: 123"placeholder case fromreact-app/src/routes.test.tsx(it asserted the placeholder this PR replaces).Storylackscontent/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 buildall pass inreact-app/.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