feature: Phase 2B — React item details feature (ItemDetails + Comment) - #714
Open
vibhaseshadri-cognition wants to merge 1 commit into
Open
vibhaseshadri-cognition wants to merge 1 commit into
vibhaseshadri-cognition wants to merge 1 commit into
Conversation
Co-Authored-By: Vibha Seshadri <vibha.seshadri@cognition.ai>
🤖 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:
|
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
Phase 2B of the Angular → React migration: ports the item details page and the recursive comment tree into
react/src/features/item/. Builds on the Phase 1 foundation (#713); no wiring into routes yet (Phase 3). Nothing outsidereact/src/features/item/is touched.Behaviour notes / deviations:
ItemDetailsreads:idviauseParams, resets state and callshackerNewsApi.fetchItemContent(itemId)on every id change, with acancelledflag so stale responses never overwrite a newer one.window.scrollTo(0, 0)runs on mount (before load, as inngOnInit). Back button →useNavigate()(-1).item.textanditem.content, which are not on the sharedStorymodel. Rather than touching the Phase 1 model,ItemDetailsuses a localtype ItemStory = Story & { text?: string; content?: string }sohead-marginand the.subjectinnerHTML behave exactly as in Angular when the API returns those fields.Comment's:host >>> a {…}styles have no React equivalent, so eachCommentroot<div>getsclassName="comment"and the SCSS uses.comment a {…}. All other class names are kept verbatim so_themes.scssglobal selectors keep working. Collapse uses the HTMLhiddenattribute so subtrees stay mounted.Rendered standalone with a mocked API (global theme styles come with Phase 3 wiring):
Angular → React mapping
src/app/item-details/item-details.component.ts/.htmlreact/src/features/item/ItemDetails.tsxsrc/app/item-details/item-details.component.scssreact/src/features/item/ItemDetails.scsssrc/app/item-details/comment/comment.component.ts/.htmlreact/src/features/item/Comment.tsxsrc/app/item-details/comment/comment.component.scssreact/src/features/item/Comment.scsssrc/app/item-details/item-details.component.spec.tsreact/src/features/item/ItemDetails.test.tsxsrc/app/item-details/comment/comment.component.spec.tsreact/src/features/item/Comment.test.tsxItemDetailsModuleexportsreact/src/features/item/index.tsTest coverage (API mocked, no network)
ItemDetails: loading state (Loader, no
.item); error textCould not load item comments.; external URL title (href,(domain)span, notarget/relby default;target="_blank" rel="noopener"whenlocalStorage.openLinkInNewTab = 'true'); no-URL story renders internalLinkto/item/:id; job type (no points/user, no comment link,item-headerpresent, noitem-detailsclass);comments_count0 non-job → noitem-header;head-marginonly whentextset; poll bars 30/90 of 120 →25%/75%plusN points;contentrendered as HTML; back button navigates to previous history entry;scrollTo(0,0)called before fetch resolves; 3-level nested comments; refetch on id change + stale response ignored; user link navigation.Comment: author link/time/innerHTML; collapse
[-]→[+],meta-collapseclass,hiddensubtree, re-expand; deleted comment renders.deleted-metaonly; 3-level recursion.Counts: 15 ItemDetails tests + 4 Comment tests = 19 new (57 total across 11 files). Coverage for
src/features/item: 99.32% lines / 97.67% branches.Checks run from
react/:npm run format,npm run lint(only pre-existing react-refresh warning),npm run format:check,npm run build,npm test,npm run test:coverage.Devin-Org: engineering
Link to Devin session: https://app.devin.ai/sessions/b23f600352164863a9fb24e24ad59970
Open in Devin Desktop: https://app.devin.ai/desktop/session/b23f600352164863a9fb24e24ad59970?variant=devin
Requested by: @vibhaseshadri-cognition