Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import ContinuousCPBar from "@/components/post_card/question_tile/continuous_cp_
import { useHideCP } from "@/contexts/cp_context";
import { QuestionStatus } from "@/types/post";
import { QuestionWithNumericForecasts, UserForecast } from "@/types/question";
import { isForecastActive } from "@/utils/forecasts/helpers";
import { formatResolution } from "@/utils/formatters/resolution";
import { isSuccessfullyResolved } from "@/utils/questions/resolution";

Expand Down Expand Up @@ -82,19 +81,17 @@ const PredictionContinuousInfo: FC<Props> = ({
/>
)}
</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 →

<div className="mt-0 flex w-full w-full border-0 border-dashed border-gray-300 pt-0 dark:border-gray-300-dark md:mt-1 md:border-t-[0.5px] md:pt-2">
<MyPredictionChip
question={question}
showUserForecast
onReaffirm={onReaffirm}
canPredict={canPredict}
variant="continuous"
/>
</div>
)}
{showMyPrediction && question.my_forecasts?.latest && (
<div className="mt-0 flex w-full w-full border-0 border-dashed border-gray-300 pt-0 dark:border-gray-300-dark md:mt-1 md:border-t-[0.5px] md:pt-2">
<MyPredictionChip
question={question}
showUserForecast
onReaffirm={onReaffirm}
canPredict={canPredict}
variant="continuous"
/>
</div>
)}
</div>
);
};
Expand Down