Repository navigation
feat: Add content follows feature for members to follow topics and posts - #941
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
React Doctor found 16 new issues in 11 files · 16 warnings · score 71 / 100 (Needs work) · 9 fixed · vs 16 warnings
Reviewed by React Doctor for commit |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ccd91d91e2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| <FollowPreferencesCard | ||
| emailAvailable={emailChannelState(data.types) !== "unavailable"} | ||
| followEmailEnabled={data.followEmailEnabled} |
There was a problem hiding this comment.
Include follow email in the account email switch state
When a member's per-type email modes are all none but an active follow uses email, followEmailEnabled defaults to true and follow emails still send. However, NotificationChannelsGroup still receives emailChannelState(data.types), so the account email switch appears off and cannot directly mute those emails; clicking it instead enables per-type emails. Derive the switch state from the follow email setting as well, so the displayed account-wide state agrees with delivery and members can stop follow emails without first enabling other notifications.
Useful? React with 👍 / 👎.
| if (query.isError) { | ||
| return ( |
There was a problem hiding this comment.
Preserve loaded follow settings after a refetch failure
If the initial settings request succeeds but a later background refetch fails, TanStack Query retains query.data while setting isError. This unconditional branch replaces the saved settings and all their controls with an empty state, making previously usable settings disappear during a transient failure. Restrict the empty state to errors without data and keep the controls visible with a warning and retry for background failures, as required by the repository's error-feedback guidance.
AGENTS.md reference: AGENTS.md:L81-L81
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cf9025334b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ); | ||
| } | ||
|
|
||
| if (query.isError) { |
There was a problem hiding this comment.
Preserve loaded follow controls after a refetch failure
When a follow-state request succeeds but a later background refetch fails, TanStack Query retains query.data while setting isError. This branch replaces the existing Follow button and delivery menu with Retry, preventing the member from unfollowing or changing delivery even though their saved state is available. Restrict this replacement to failures without data; otherwise retain the controls and show a warning. AGENTS.md explicitly requires “Failed refetch over existing data → Alert variant="warning" above the content.”
AGENTS.md reference: AGENTS.md:L71-L71
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 17f2ab7829
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| prepareRef.current ??= Promise.all([ | ||
| importSearchAdminDialog(), | ||
| prepareIndex?.(), | ||
| ]) | ||
| .then(([module]) => { | ||
| setPreparedContent(() => module.SearchAdminDialogContent); |
There was a problem hiding this comment.
Render the palette before optional language requests finish
On a multilingual installation with uncached translations, opening the AdminCP palette waits for every other language's message request before mounting the searchable content. useAdminSearchIndex.prepare() awaits all those requests, so one slow request leaves the palette showing only a skeleton even though the dialog module and active-language index are ready. The 250 ms budget in useSearchMorph only opens the dialog; it does not release this dependency. Set PreparedContent when the module loads and warm the additional languages independently so users can search in the active language immediately.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 175de67087
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| const showDoc = (doc: PMNode, range: QuickAskRange) => { | ||
| const { state, view } = editor; | ||
| view.dispatch(state.tr.replaceWith(0, state.doc.content.size, doc.content)); |
There was a problem hiding this comment.
Preserve concurrent edits when switching Quick Ask versions
In a collaborative editor, another member can edit the document while the Quick Ask review bar remains open. showDoc replaces the entire current document with a saved snapshot, so choosing Original, Rewritten, Retry, or Undo discards any remote edits received since that snapshot, including changes outside the AI-edited selection, and propagates those deletions to collaborators. This affects the existing ContentLiveRichTextEditor collaboration binding and blog posts, which enable liveEditing. Apply a range-scoped, mapped change instead of restoring the whole document, or invalidate the review when intervening edits make restoration unsafe.
Useful? React with 👍 / 👎.
| selection: doc | ||
| .textBetween(from, to, "\n", " ") | ||
| .slice(0, QUICK_ASK_CLIENT_LIMITS.selection), |
There was a problem hiding this comment.
Reject oversized selections before replacing their full range
When a member selects more than 8,000 characters and runs Proofread or Rewrite, only the first 8,000 characters reach the model, but useQuickAskReview.commit passes the entire original selection range to applyQuickAskResult. The generated answer therefore replaces—and deletes—the unprocessed remainder of the selection. The previous flow prevented replacement through its stale-snapshot check, which is absent from the new runner. Reject oversized selections with feedback, process them completely, or restrict replacement to the text actually submitted.
Useful? React with 👍 / 👎.
- Record follows for threaded Content Engine roots, with auto-follow, follow preferences and follower notification delivery - Follow control (icon list) and followers dialog in core, follow card in notification settings, wired into blog posts and forum topics - Search key hints shared by header and AdminCP search dialogs - Required relations for content types, slug sync from source fields - Dashboard incoming items and sign-ups chart tooltips - Tests for follow routes, persistence, config validation and UI Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
175de67 to
fbc9fce
Compare
| contentFollowAvailability(c, definition.id), | ||
| ]); | ||
| // After the write, so the count includes this follow. | ||
| const followerCount = await countContentFollowers(c.get("db"), record); |
There was a problem hiding this comment.
React Doctor · react-doctor/server-sequential-independent-await (warning)
This awaited initializer does not read the previous result. If the operations are independent asynchronous work, they may overlap; await syntax alone does not establish a speedup.
Fix → Consider Promise.all([...]) only for independent asynchronous work. Shared queues or synchronous work may not benefit. Preserve resource limits, transaction ordering, and failure/cancellation semantics.
| } | ||
| if (firstPublishedAt) { | ||
| for (const rule of followerRules) { | ||
| await dispatchContentNotificationIntent(c, tx, { |
There was a problem hiding this comment.
React Doctor · react-doctor/async-await-in-loop (warning)
This for…of loop waits before starting the next iteration. If iterations perform independent asynchronous work, consider bounded concurrency; await syntax alone does not establish a speedup.
Fix → Consider concurrent calls only for independent asynchronous work. Shared queues or synchronous work may not benefit. Preserve resource limits, transaction ordering, and failure/cancellation semantics; observe all callback promises.
|
|
||
| const MORPH_MS = 300; | ||
|
|
||
| const QuickAskPanel = ({ |
There was a problem hiding this comment.
React Doctor · react-doctor/no-giant-component (warning)
Component "QuickAskPanel" is over 300 lines long, which is hard to read & change. Split it into a few smaller components.
Fix → Pull each section into its own component so the parent is easier to read, test, and change.
|
|
||
| const MORPH_MS = 300; | ||
|
|
||
| const QuickAskPanel = ({ |
There was a problem hiding this comment.
React Doctor · react-doctor/no-high-complexity-react-function (warning)
QuickAskPanel has cyclomatic complexity 38, cognitive complexity 63, and maximum nesting depth 3, so its React logic is hard to understand and change. Extract independent branches into components or hooks.
Fix → Extract independent render branches and state logic into focused components or hooks until the control flow is easy to follow.
| for (const group of selection ? SELECTION_GROUPS : CARET_GROUPS) { | ||
| for (const operation of group.operations) { | ||
| if (!allowed({ kind: "operation", operation })) continue; | ||
| if (!q && tiles.includes(operation)) continue; |
There was a problem hiding this comment.
React Doctor · react-doctor/js-set-map-lookups (warning)
This scales poorly because array.includes() inside a loop scans the whole list every time. Use a Set for constant-time lookups.
Fix → Use a Set or Map when you check for the same items over and over. Array.includes/find scans the whole list each time
| aria-expanded={entries.length > 0} | ||
| aria-label={t("search.label")} | ||
| autoComplete="off" | ||
| autoFocus |
There was a problem hiding this comment.
React Doctor · react-doctor/no-autofocus (warning)
autoFocus moves focus on load, which can disrupt screen reader and keyboard users. Remove it and let users choose where to focus.
Fix → Do not use autoFocus. It disorients users on load.
| continue; | ||
| } | ||
|
|
||
| const source = spec.fields.find( |
There was a problem hiding this comment.
React Doctor · react-doctor/js-index-maps (warning)
This gets slow as your list grows because array.find() runs inside a loop, so build a Map once before the loop for instant lookups
Fix → Build a Map once before the loop instead of calling array.find(...) inside it
|
|
||
| const header = ( | ||
| <FrameHeader> | ||
| <FrameTitle id={titleId} render={<h2 />}> |
There was a problem hiding this comment.
React Doctor · react-doctor/heading-has-content (warning)
Blind users can't use this heading to navigate because screen readers skip it empty, so add text, aria-label, or aria-labelledby.
Fix → Put readable text in every heading.
| <FrameTitle | ||
| className="flex items-center gap-2" | ||
| id={titleId} | ||
| render={<h2 />} |
There was a problem hiding this comment.
React Doctor · react-doctor/heading-has-content (warning)
Blind users can't use this heading to navigate because screen readers skip it empty, so add text, aria-label, or aria-labelledby.
Fix → Put readable text in every heading.
| field => statusOf(field, language.code) === "missing", | ||
| ).length, | ||
| name: language.name, | ||
| outdated: outdated.includes(language.code), |
There was a problem hiding this comment.
React Doctor · react-doctor/js-set-map-lookups (warning)
This scales poorly because array.includes() inside a loop scans the whole list every time. Use a Set for constant-time lookups.
Fix → Use a Set or Map when you check for the same items over and over. Array.includes/find scans the whole list each time
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fbc9fce1ef
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| setQuery(""); | ||
| void review.write( |
There was a problem hiding this comment.
Engage the Quick Ask session before running a clicked action
When a member selects text and clicks Proofread or Rewrite directly in the automatically opened popover, the session still has focus: false: the option's mouse-down handler preserves editor focus, and choose never calls quickAsk.focusPrompt(). Applying the answer collapses the editor selection, so the selection-settle handler in useQuickAskSession closes the session after 220 ms. The Original/Rewritten, Retry, and Undo controls consequently disappear before the member can review the replacement. Mark the session as engaged before starting the AI action so selection updates caused by applying its answer do not dismiss the review.
Useful? React with 👍 / 👎.
| ); | ||
| } | ||
|
|
||
| if (query.isError) { |
There was a problem hiding this comment.
Preserve loaded followers when a subsequent request fails
After the first followers page loads, a failed next-page request or background refetch sets query.isError while retaining the loaded pages. This unconditional branch replaces those usable followers with an empty error state, so scrolling into a transient pagination failure makes the entire list disappear. Restrict the replacement to errors without data; retain existing rows and expose a warning with an appropriate retry for subsequent failures. AGENTS.md requires failed refetches over existing data to show an Alert variant="warning" above the content.
AGENTS.md reference: AGENTS.md:L71-L71
Useful? React with 👍 / 👎.
Description
What?
Implements a complete content follows system allowing signed-in members to follow forum topics and blog posts, receiving notifications about new comments and replies. This includes:
core_content_followstable to track which members follow which content items/{id}/followendpoints for managing follows with delivery preferences (in-app, email modes)rootFollowers: trueandmessages.followedContentFollowButtoncomponent with dropdown menu for delivery preferences and follow state managementWhy?
This feature enhances member engagement by allowing them to stay updated on discussions they care about. Members can customize how they receive notifications (in-app only, immediate email, daily/weekly digests) and set account-wide defaults. The implementation integrates deeply with the existing notification system to ensure follows respect member preferences and email configuration.
Key Changes
follow: trueoption todefineContentType()for forum topics and blog postsbuildContentNotifications()withrootFollowers: trueandmessages.followedfor threadReply rulesTest Plan
Existing test suites cover the implementation:
follows.postgres.test.ts: 1277-line integration test covering follow creation, deletion, notification delivery, email digests, and multi-page follower scenariosfollow-button.test.tsx: React component tests for follow UI interactions and state managementsettings-screen.test.tsx: Account settings tests for follow preferencespreferences.test.ts: Notification channel resolution with follow contextfollow.test.ts: Follow preference resolution logicquery.test.ts: Follow query validationCI passes with all tests included.