Skip to content

Sidebar reflow#4660

Merged
ncarazon merged 8 commits intofeat/question-page-redesign-1st-iterationfrom
feat/sidebar-reflow
May 1, 2026
Merged

Sidebar reflow#4660
ncarazon merged 8 commits intofeat/question-page-redesign-1st-iterationfrom
feat/sidebar-reflow

Conversation

@ncarazon
Copy link
Copy Markdown
Contributor

@ncarazon ncarazon commented Apr 27, 2026

Related to #4640

This PR delivers the question page sidebar reflow and redesigns of the Similar Questions section.

Sidebar reflow (forecaster vs consumer):

  • Forecaster desktop sidebar: SidebarQuestionInfo + SimilarQuestions
  • Consumer desktop sidebar: SimilarQuestions only
  • Removed from the desktop sidebar for both variants: PostSubscribeButton, SharePostMenu, QuestionEmbedButton, PostDropdownMenu, SidebarQuestionProjects

Similar Questions redesign:

  • New card layout: centered stats row (comments + forecasters) → centered title → chart
  • Charts are now enabled per question type. Reuses existing QuestionTile and GroupOfQuestionsTile
  • Forecaster cards include a footer row: vote buttons, comment count, status icon, forecaster count
  • Consumer view: group questions reuse GroupForecastCard (the same charts from consumer post cards). FanGraph groups render TimeSeriesChart, numeric groups render NumericForecastCard, date groups render NumericForecastCard compact (horizontal bars)
  • Fixed vote not updating on reload in similar question cards: getSimilarPosts used a 1-hour revalidating cache and the backend omitted current_user from serialization, so user_vote was always null and PostVoter's initial state always rendered grey. Backend still needs to correctly pass current_user in serialization for green highlighting to work

Consumer

consumer.mp4

Forecaster

forecaster.mp4

Summary by CodeRabbit

  • New Features

    • Implemented variant-specific sidebar layouts for forecasters and consumers, displaying tailored question information and similar questions based on user type.
    • Consumer view now displays forecast cards and community engagement metrics (comment counts, forecaster counts).
    • Forecaster view includes voting controls and resolution status indicators for similar questions.
  • Style

    • Updated sidebar container styling and question layout presentation for improved visual clarity.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 27, 2026

📝 Walkthrough

Walkthrough

The PR introduces variant-based conditional rendering throughout the sidebar and related components, allowing forecaster and consumer UI variants to be displayed based on user type. The backend is updated to conditionally include user forecasts in post serialization based on a new flag.

Changes

Cohort / File(s) Summary
Page Composition & Layout
front_end/src/app/(main)/questions/[id]/page_component.tsx, front_end/src/app/(main)/questions/[id]/components/question_layout/question_info.tsx
Integrate QuestionVariantComposer to wire variant-specific sidebar rendering, with consumer variant displaying SidebarQuestionInfo and forecaster variant disabled via null.
Sidebar Core & Container
front_end/src/app/(main)/questions/[id]/components/sidebar/index.tsx, front_end/src/app/(main)/questions/[id]/components/sidebar/sidebar_container.tsx
Add optional variant prop to Sidebar, gate SidebarContainer rendering on variant === "forecaster", forward variant to SimilarQuestions, and update container styling with blue border.
Similar Questions Components
front_end/src/app/(main)/questions/[id]/components/sidebar/similar_questions/index.tsx, .../similar_question_card.tsx, .../similar_question_prediction_chip.tsx, .../similar_questions_list.tsx, .../similar_questions_drawer.tsx
Replace SimilarQuestionsDrawer with SimilarQuestionsList, add variant prop to components, implement variant-based rendering with consumer mode using forecast-oriented cards and forecaster mode with voting controls and status icons.
Post Card Components
front_end/src/components/consumer_post_card/group_forecast_card/index.tsx, front_end/src/components/post_card/basic_post_card/post_voter.tsx, front_end/src/components/post_card/question_tile/question_continuous_tile.tsx
Add compact prop to PostVoter for smaller text sizing, add conditional compact rendering in GroupForecastCard for date questions, adjust flex alignment in QuestionContinuousTile.
API & Backend Serialization
front_end/src/services/api/posts/posts.shared.ts, posts/serializers.py, posts/views.py
Remove Next.js revalidation metadata from getSimilarPosts, add include_user_forecasts flag to serialize_post_many, and pass flag through multiple view endpoints to conditionally prefetch user forecasts.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

Possibly related PRs

  • Question page - Meta row #4640 — Modifies the same sidebar component (index.tsx) to introduce variant-based conditional rendering logic for question detail views.
  • Unify consumer notebooks representation #4126 — Updates QuestionVariantComposer invocation and prop usage, which is the key architectural component orchestrating variant selection in this PR.
  • Metaculus Storefront #4522 — Adds and propagates the compact prop through consumer post card components, overlapping with the GroupForecastCard and PostVoter changes in this PR.

Suggested reviewers

  • elisescu
  • cemreinanc
  • lsabor
  • hlbmtc

Poem

🐰 A sidebar splits in two today,
Forecaster here, consumer there—they say!
Variants flow like carrots down the tree,
Each path renders differently! 🥕✨

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Sidebar reflow' is vague and generic; it does not convey specific information about the comprehensive redesign of the Similar Questions section or the multi-variant sidebar composition changes that constitute the main work in this changeset. Consider a more descriptive title that captures the main changes, such as 'Redesign Similar Questions section with variant-specific sidebar layouts' or 'Implement forecaster/consumer sidebar variants with redesigned Similar Questions cards'.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/sidebar-reflow

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.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 27, 2026

Cleanup: Preview Environment Removed

The preview environment for this PR has been destroyed.

Resource Status
🌐 Preview App Deleted
🗄️ PostgreSQL Branch Deleted
⚡ Redis Database Deleted
🔧 GitHub Deployments Removed
📦 Docker Image Retained (auto-cleanup via GHCR policies)

Cleanup triggered by PR close at 2026-05-01T09:46:42Z

@ncarazon ncarazon force-pushed the feat/sidebar-reflow branch from 160e699 to 643caef Compare April 28, 2026 14:29
{
next: { revalidate: 3600 },
}
`/posts/${postId}/similar-posts/`
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

To BE engineer that reviews it. Similar questions will now have post voter element in forecaster mode. I this FE tweak to allow getting the updated votes on page reload, but BE logic still needs adjustment, since right now it won't return "voted" state to render highlights on FE. Potential reason for that is described in PR description. I would appreciate a proper fix (either to this PR or as a separate branch).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@ncarazon Added here -- c1d54e2

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks! 🙌

@ncarazon ncarazon marked this pull request as ready for review April 28, 2026 14:34
@hlbmtc
Copy link
Copy Markdown
Contributor

hlbmtc commented Apr 28, 2026

A quick question: should we adjust comments section width as well?
image

@ncarazon
Copy link
Copy Markdown
Contributor Author

A quick question: should we adjust comments section width as well? image

Yeah, but not in this PR. I'm gonna put 2 more PRs on the first iteration for this feature, which will wrap up the desktop UI and mobile UI using all building blocks that were implemented in previous PRs. Thanks for notice though.

@hlbmtc
Copy link
Copy Markdown
Contributor

hlbmtc commented Apr 29, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 29, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
front_end/src/app/(main)/questions/[id]/components/sidebar/similar_questions/similar_question_card.tsx (1)

23-136: Defer resolution extraction to the forecaster branch.

extractPostResolution(post) is only used in the footer that renders for variant === "forecaster", so the consumer path is doing extra work for no visible benefit.

♻️ Suggested tweak
-  const resolutionData = extractPostResolution(post);
-
   return (
@@
       {isForecaster && (
         <div className="flex items-center gap-1.5">
           <PostVoter post={post} compact className="h-6" />
@@
             <PostStatusIcon
               status={post.status}
               published_at={post.published_at}
               open_time={post.open_time}
               scheduled_close_time={post.scheduled_close_time}
-              resolution={resolutionData}
+              resolution={extractPostResolution(post)}
             />
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@front_end/src/app/`(main)/questions/[id]/components/sidebar/similar_questions/similar_question_card.tsx
around lines 23 - 136, The call to extractPostResolution(post) is done
unconditionally in SimilarQuestionCard even though resolutionData is only passed
into PostStatusIcon when variant === "forecaster"; move the extraction into the
forecaster branch so you only compute resolutionData when needed: remove the
top-level const resolutionData = extractPostResolution(post) and instead call
extractPostResolution(post) (assigning to resolutionData) inside the
isForecaster conditional before rendering PostStatusIcon (used in the footer),
ensuring you pass that local resolutionData into PostStatusIcon.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@front_end/src/app/`(main)/questions/[id]/components/sidebar/similar_questions/similar_question_card.tsx:
- Around line 23-136: The call to extractPostResolution(post) is done
unconditionally in SimilarQuestionCard even though resolutionData is only passed
into PostStatusIcon when variant === "forecaster"; move the extraction into the
forecaster branch so you only compute resolutionData when needed: remove the
top-level const resolutionData = extractPostResolution(post) and instead call
extractPostResolution(post) (assigning to resolutionData) inside the
isForecaster conditional before rendering PostStatusIcon (used in the footer),
ensuring you pass that local resolutionData into PostStatusIcon.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2853671c-5b44-42a3-be3e-877fa1988759

📥 Commits

Reviewing files that changed from the base of the PR and between 6b4cd20 and c1d54e2.

📒 Files selected for processing (15)
  • front_end/src/app/(main)/questions/[id]/[[...slug]]/page_component.tsx
  • front_end/src/app/(main)/questions/[id]/components/question_layout/question_info.tsx
  • front_end/src/app/(main)/questions/[id]/components/sidebar/index.tsx
  • front_end/src/app/(main)/questions/[id]/components/sidebar/sidebar_container.tsx
  • front_end/src/app/(main)/questions/[id]/components/sidebar/similar_questions/index.tsx
  • front_end/src/app/(main)/questions/[id]/components/sidebar/similar_questions/similar_question_card.tsx
  • front_end/src/app/(main)/questions/[id]/components/sidebar/similar_questions/similar_question_prediction_chip.tsx
  • front_end/src/app/(main)/questions/[id]/components/sidebar/similar_questions/similar_questions_drawer.tsx
  • front_end/src/app/(main)/questions/[id]/components/sidebar/similar_questions/similar_questions_list.tsx
  • front_end/src/components/consumer_post_card/group_forecast_card/index.tsx
  • front_end/src/components/post_card/basic_post_card/post_voter.tsx
  • front_end/src/components/post_card/question_tile/question_continuous_tile.tsx
  • front_end/src/services/api/posts/posts.shared.ts
  • posts/serializers.py
  • posts/views.py
💤 Files with no reviewable changes (1)
  • front_end/src/app/(main)/questions/[id]/components/sidebar/similar_questions/similar_questions_drawer.tsx

@ncarazon ncarazon merged commit f118806 into feat/question-page-redesign-1st-iteration May 1, 2026
13 checks passed
@ncarazon ncarazon deleted the feat/sidebar-reflow branch May 1, 2026 09:46
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.

3 participants