fix: hide unlisted secondary project chips across question page & notebook#4895
fix: hide unlisted secondary project chips across question page & notebook#4895SylvainChevalier wants to merge 1 commit into
Conversation
…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>
📝 WalkthroughWalkthroughThree components — the notebook editor, the question meta row, and the question info tab — now import ChangesUnlisted Project Visibility Filtering
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
🚀 Preview EnvironmentYour preview environment is ready!
Details
ℹ️ Preview Environment InfoIsolation:
Limitations:
Cleanup:
|
|
lgtm. |
There was a problem hiding this comment.
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
📒 Files selected for processing (3)
front_end/src/app/(main)/notebooks/components/notebook_editor/index.tsxfront_end/src/app/(main)/questions/[id]/components/question_page_shell/meta_row.tsxfront_end/src/app/(main)/questions/[id]/components/question_page_shell/tabs/question_info.tsx
| ].filter( | ||
| (p) => | ||
| defaultProject && | ||
| p.id !== defaultProject.id && | ||
| (!("visibility" in p) || p.visibility !== ProjectVisibility.Unlisted) | ||
| ); |
There was a problem hiding this comment.
🧩 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 -40Repository: 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.
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 toallProjects.notebook_editor/index.tsx: add unlisted-visibility guard tootherProjects.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