fix(activity-feed-v2): Show Edited indicator and fix version mapping#4570
Conversation
- Populate TextMessageType.updatedAt from modified_at when it differs from created_at so threaded-annotations renders the Edited indicator after a successful edit. - Thread the message author id through textToDocumentNode so each mention node carries the correct authorId instead of an empty string. - Derive version action from version_promoted, restored_at and trashed_at flags before falling back to action_type, matching v1 behavior. Restore v1 priority for the version author (restored_by -> trashed_by -> promoted_by -> modified_by).
WalkthroughThe PR extends the activity feed transformers to support mention author attribution and message modification timestamps. Text parsing now accepts and propagates an ChangesActivity Feed Transformer Enhancements
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/elements/content-sidebar/activity-feed-v2/__tests__/transformers.test.ts (1)
427-455: ⚡ Quick winAdd an explicit
restored_byprecedence regression test.The new ordering puts
restored_byahead of the other version user fields, but the suite only locks in promotion precedence and a trashed fallback. A small restore case would guard the highest-priority branch against future reorder regressions.Suggested test shape
+ test('should prefer restored_by over other version users', () => { + const version = { + ...mockVersion, + action_type: undefined, + modified_by: { id: '300', name: 'Uploader', type: 'user' }, + promoted_by: { id: '500', name: 'Promoter', type: 'user' }, + restored_at: '2024-04-02T00:00:00Z', + restored_by: { id: '600', name: 'Restorer', type: 'user' }, + }; + const result = transformVersionToProps(version as unknown as BoxItemVersion); + expect(result.authorName).toBe('Restorer'); + expect(result.actionType).toBe('restore'); + });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/elements/content-sidebar/activity-feed-v2/__tests__/transformers.test.ts` around lines 427 - 455, Add a unit test in the same suite to assert restored_by takes precedence for author and yields a restore action: create a version object based on mockVersion with restored_at set (or action_type: 'restored'), include restored_by: { id: '700', name: 'Restorer', type: 'user' } plus other user fields like modified_by and uploaded_by with different names, call transformVersionToProps(version as unknown as BoxItemVersion) and expect authorName toBe 'Restorer' and actionType toBe 'restore' to lock in restored_by precedence in transformVersionToProps.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In
`@src/elements/content-sidebar/activity-feed-v2/__tests__/transformers.test.ts`:
- Around line 427-455: Add a unit test in the same suite to assert restored_by
takes precedence for author and yields a restore action: create a version object
based on mockVersion with restored_at set (or action_type: 'restored'), include
restored_by: { id: '700', name: 'Restorer', type: 'user' } plus other user
fields like modified_by and uploaded_by with different names, call
transformVersionToProps(version as unknown as BoxItemVersion) and expect
authorName toBe 'Restorer' and actionType toBe 'restore' to lock in restored_by
precedence in transformVersionToProps.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: fd316ca9-9f51-442a-b070-f0c505206f11
📒 Files selected for processing (2)
src/elements/content-sidebar/activity-feed-v2/__tests__/transformers.test.tssrc/elements/content-sidebar/activity-feed-v2/transformers.ts
Merge Queue Status
This pull request spent 43 seconds in the queue, including 6 seconds running CI. Required conditions to merge
|
Summary
Three fixes to the new ActivityFeedV2 transformer layer so it matches v1 behavior:
TextMessageType.updatedAtfrommodified_atwhen it differs fromcreated_at. After editing a comment or annotation, threaded-annotations now renders the "Edited" label.authorId: thread the message author id throughtextToDocumentNodeso each mention node carriesauthorId: comment.created_by.id(or annotation creator) instead of an empty string. This restores thedata-author-idattribute on rendered mention elements.version_promoted/restored_at/trashed_atflags before falling back toaction_type, matching v1'sselectors/version.js. Restore v1 priority for the version author (restored_by->trashed_by->promoted_by->modified_by); the previous v2 ordering preferredmodified_byand so showed the wrong actor for promote/restore/delete events.Test plan
yarn test --watchAll=false --testPathPattern="activity-feed-v2"(136/136 pass, 16 new tests)data-author-idis the comment/annotation author idSummary by CodeRabbit
New Features
Tests