Skip to content

fix: hide unlisted secondary project chips across question page & notebook#4895

Open
SylvainChevalier wants to merge 1 commit into
mainfrom
claude/issue-4687-only-show-unlisted-project-chip
Open

fix: hide unlisted secondary project chips across question page & notebook#4895
SylvainChevalier wants to merge 1 commit into
mainfrom
claude/issue-4687-only-show-unlisted-project-chip

Conversation

@SylvainChevalier

@SylvainChevalier SylvainChevalier commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Closes #4687

Summary

The earlier fix only filtered unlisted secondary projects in the question page sidebar. The same concatenated project list also renders in the header meta row (with a “N more” popover), the Question Info tab, and the notebook reader — so unlisted secondary projects were still visible there.

Changes

  • meta_row.tsx: add unlisted-visibility guard to the dedup/filter chain.
  • question_info.tsx: add unlisted-visibility guard to allProjects.
  • notebook_editor/index.tsx: add unlisted-visibility guard to otherProjects.

In every case the default (main) project is still shown even if it’s unlisted; only secondary unlisted projects are dropped.

Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved project visibility filtering across notebooks and question pages. Unlisted projects are now properly hidden from view, except when designated as the default project, providing a cleaner and more organized interface.

…nfo tab and notebook

The previous fix only covered the sidebar chip list. The header meta row,
the Question Info tab, and the notebook reader concatenate the same
project arrays and were still rendering unlisted secondary projects.

Co-authored-by: Sylvain <SylvainChevalier@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Three components — the notebook editor, the question meta row, and the question info tab — now import ProjectVisibility and add a filter that hides Unlisted projects from rendered chip/project lists unless the unlisted project's id matches the current default project id.

Changes

Unlisted Project Visibility Filtering

Layer / File(s) Summary
Question page unlisted project chip filtering
front_end/src/app/(main)/questions/[id]/components/question_page_shell/meta_row.tsx, front_end/src/app/(main)/questions/[id]/components/question_page_shell/tabs/question_info.tsx
Both components import ProjectVisibility, derive defaultProjectId, and update their allProjects filter predicate to keep Unlisted projects only when their id matches defaultProjectId.
Notebook editor unlisted project filtering
front_end/src/app/(main)/notebooks/components/notebook_editor/index.tsx
Imports ProjectVisibility and extends the otherProjects filter to exclude ProjectVisibility.Unlisted projects (when visibility is defined) before merging into allProjects.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • Metaculus/metaculus#3935: Modifies notebook_editor/index.tsx project-chip rendering logic, which this PR also changes to add ProjectVisibility filtering.
  • Metaculus/metaculus#4690: Adds the same ProjectVisibility.Unlisted chip-filtering pattern to question UI components that this PR extends.

Suggested reviewers

  • hlbmtc
  • ncarazon

Poem

🐇 A rabbit hopped through the chip display,
Spotting unlisted projects in the fray.
"Only the default may show its face!"
It filtered them out with elegant grace.
Now only the chosen project shines bright—
Unlisted ones hidden, tucked out of sight! 🌟

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: hide unlisted secondary project chips across question page & notebook' accurately describes the main change—filtering unlisted secondary projects in multiple UI locations.
Linked Issues check ✅ Passed The changes implement the requirement from #4687 to hide unlisted secondary projects while showing the main project, extending the fix across all three locations (meta_row, question_info, notebook_editor).
Out of Scope Changes check ✅ Passed All changes directly address the filtering of unlisted secondary projects in the three specified components; no unrelated modifications are present.

✏️ 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 claude/issue-4687-only-show-unlisted-project-chip

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

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

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Preview Environment

Your preview environment is ready!

Resource Details
🌐 Preview URL https://metaculus-pr-4895-claude-issue-4687-only-show-un-preview.mtcl.cc
📦 Docker Image ghcr.io/metaculus/metaculus:claude-issue-4687-only-show-unlisted-project-chip-cfcc651
🗄️ PostgreSQL NeonDB branch preview/pr-4895-claude-issue-4687-only-show-un
Redis Fly Redis mtc-redis-pr-4895-claude-issue-4687-only-show-un

Details

  • Commit: 621676e033191a1543c4190276bb14834464d894
  • Branch: claude/issue-4687-only-show-unlisted-project-chip
  • Fly App: metaculus-pr-4895-claude-issue-4687-only-show-un

ℹ️ Preview Environment Info

Isolation:

  • PostgreSQL and Redis are fully isolated from production
  • Each PR gets its own database branch and Redis instance
  • Changes pushed to this PR will trigger a new deployment

Limitations:

  • Background workers and cron jobs are not deployed in preview environments
  • If you need to test background jobs, use Heroku staging environments

Cleanup:

  • This preview will be automatically destroyed when the PR is closed

@SylvainChevalier

Copy link
Copy Markdown
Contributor Author

lgtm.

@SylvainChevalier SylvainChevalier marked this pull request as ready for review June 17, 2026 12:51

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@front_end/src/app/`(main)/notebooks/components/notebook_editor/index.tsx:
- Around line 92-97: The filter predicate for the `otherProjects` array
incorrectly gates the entire filter on `defaultProject` existence, causing it to
return false for all projects when `defaultProject` is null or undefined,
resulting in an empty array. Fix this by removing the `defaultProject &&` guard
at the beginning of the predicate and instead use optional chaining when
accessing the defaultProject.id property in the comparison (e.g., `p.id !==
defaultProject?.id`), or use a conditional expression like `(!defaultProject ||
p.id !== defaultProject.id)`. This allows the filter to properly include other
projects even when `defaultProject` is absent, while still excluding the default
project when it exists.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 52380d82-3922-4834-84f1-0fdfac0ef889

📥 Commits

Reviewing files that changed from the base of the PR and between 41be389 and cfcc651.

📒 Files selected for processing (3)
  • front_end/src/app/(main)/notebooks/components/notebook_editor/index.tsx
  • front_end/src/app/(main)/questions/[id]/components/question_page_shell/meta_row.tsx
  • front_end/src/app/(main)/questions/[id]/components/question_page_shell/tabs/question_info.tsx

Comment on lines +92 to +97
].filter(
(p) =>
defaultProject &&
p.id !== defaultProject.id &&
(!("visibility" in p) || p.visibility !== ProjectVisibility.Unlisted)
);

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.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify whether default_project is guaranteed in NotebookPost/project payload shapes.

set -euo pipefail

echo "== Locate NotebookPost and project type definitions =="
fd -i 'post*.ts' front_end src || true
rg -n --type=ts -C3 '\binterface\s+NotebookPost\b|\btype\s+NotebookPost\b|\bdefault_project\b|\bprojects\??\s*:' front_end src

echo
echo "== Inspect notebook editor usages and any guards for missing default_project =="
rg -n --type=tsx -C3 'NotebookEditor|default_project|projects\?.*index|projects\?.*tournament' front_end src

echo
echo "== Look for serializers/API contracts that define notebook projects payload =="
rg -n -C2 'default_project|question_series|leaderboard_tag|visibility' .

Repository: Metaculus/metaculus

Length of output: 50487


🏁 Script executed:

cat -n front_end/src/app/\(main\)/notebooks/components/notebook_editor/index.tsx | head -120 | tail -40

Repository: Metaculus/metaculus

Length of output: 1559


The otherProjects filter incorrectly gates on defaultProject presence, collapsing the array when defaultProject is missing.

At line 94, the predicate defaultProject && ... short-circuits the entire filter to false for every project when defaultProject is null or undefined. This causes otherProjects to become an empty array, even though the fallback at line 99-101 suggests the code expects otherProjects to contain projects when defaultProject is absent.

Fix: Change line 94 from:

defaultProject &&

to either:

(!defaultProject || p.id !== defaultProject.id) &&

or apply optional chaining:

(p.id !== defaultProject?.id) &&

This allows the filter to exclude only the default project when present, while still including other projects when defaultProject is missing.

🤖 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 `@front_end/src/app/`(main)/notebooks/components/notebook_editor/index.tsx
around lines 92 - 97, The filter predicate for the `otherProjects` array
incorrectly gates the entire filter on `defaultProject` existence, causing it to
return false for all projects when `defaultProject` is null or undefined,
resulting in an empty array. Fix this by removing the `defaultProject &&` guard
at the beginning of the predicate and instead use optional chaining when
accessing the defaultProject.id property in the comparison (e.g., `p.id !==
defaultProject?.id`), or use a conditional expression like `(!defaultProject ||
p.id !== defaultProject.id)`. This allows the filter to properly include other
projects even when `defaultProject` is absent, while still excluding the default
project when it exists.

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.

Only show unlisted project chip if it's the main project of the question

1 participant