Skip to content

Conversation

@SylvainChevalier
Copy link
Contributor

Summary

This PR fixes the issue where user predictions were not visible on closed numeric and date questions.

Changes

  • Removed the isForecastActive() check that was preventing predictions from displaying on closed questions
  • Cleaned up unused import

The prediction data is always available and should be shown regardless of whether the question is closed, matching the behavior in feed tiles and the "Overlay Current Forecast" feature.

Fixes #4009

🤖 Generated with Claude Code

Removed the isForecastActive() check that was preventing user predictions
from being displayed on closed numeric and date questions. The prediction
data is available and should be shown regardless of question status.

Fixes #4009

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

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
</div>
{showMyPrediction &&
question.my_forecasts?.latest &&
isForecastActive(question.my_forecasts.latest) && (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@claude
I suspect we added isForecastActive so we don't show withdrawn predictions. Cases:

  • Question open and prediction not withdrawn yet: show.
  • Question open and prediction withdrawn: don't show.
  • Question closed and prediction not withdrawn before close: show.
  • Question closed and prediction withdrawn before close: don't show.

Copy link

@claude claude bot Jan 12, 2026

Choose a reason for hiding this comment

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

Claude finished @SylvainChevalier's task in 1m 3s —— View job


Analysis: Withdrawn Predictions Concern

You're absolutely right to be concerned! Here's what I found:

What isForecastActive() Does

From front_end/src/utils/forecasts/helpers.ts:136-138:

export function isForecastActive(forecast: UserForecast | AggregateForecast) {
  return isNil(forecast.end_time) || forecast.end_time * 1000 > Date.now();
}

This checks if a forecast is not withdrawn by verifying that either:

  • end_time is null/undefined (forecast never withdrawn), OR
  • end_time is in the future (hasn't ended yet)

The Problem with the Current PR

MyPredictionChip ALREADY has the isForecastActive() check inside it (my_prediction_chip.tsx:39), so removing it from the parent seems safe at first glance. However, there's a subtle issue:

The current PR removes the check from prediction_continuous_info.tsx, but prediction_binary_info.tsx:81 still has it. This creates an inconsistency between binary and continuous questions.

Case Analysis

Let me verify all four cases:

Case Question State Prediction State Should Show? Current PR Behavior
1 Open Not withdrawn ✅ Show ✅ Shows (pass isForecastActive in chip)
2 Open Withdrawn ❌ Don't show ✅ Hidden (fail isForecastActive in chip)
3 Closed Not withdrawn before close ✅ Show ✅ Shows (pass isForecastActive in chip)
4 Closed Withdrawn before close ❌ Don't show ✅ Hidden (fail isForecastActive in chip)

Verdict

The current PR is actually correct! 🎉

The MyPredictionChip component already handles the withdrawn check internally at line 39, so:

  • Removing the duplicate check from the parent is correct
  • All four cases are handled properly through the child component's check

Recommendation

For consistency, prediction_binary_info.tsx should also have the same fix applied - it currently has a redundant isForecastActive check at line 81 that can be removed since MyPredictionChip handles it.

Would you like me to apply the same fix to the binary version for consistency? Fix this →

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.

Numeric and date questions fail to show my prediction when they're closed

2 participants