发布

  • [OPIK-7458] [FE] fix: name the real cause when an optimization run shows nothing usable (#7627)

    frostbyte_neo 发布于 2026-07-31 10:52:23 +00:00

    • [OPIK-7458] [FE] fix: name the real cause when an optimization run shows nothing usable

    A COMPLETED run whose optimizer produced no candidates beyond the baseline
    showed "No usable scores, the metric may have failed on every item", even
    though the metric worked and the baseline was scored. That is the common
    "already-good prompt" outcome, not an error, so the copy was misleading.

    One boolean carried two causes. It is now an explicit classifier:

    • computeEmptyRunCause() replaces computeEmptyRunWarning(). NO_CANDIDATES when
      nothing was generated but the baseline scored; SCORING_FAILED when candidates
      ran without scoring, or when nothing scored at all (the old vacuous every()
      could not tell those apart); NONE otherwise.
    • scoring_health keeps its exact-count precedence for SCORING_FAILED only. For
      NO_CANDIDATES it is ignored, since the baseline scored and per-item failure
      counts cannot explain the outcome. This removes the total_count === 0
      fall-through that routed candidate-less runs into the metric-failure copy.
    • The panel takes the cause and picks severity from a single cause-keyed
      appearance map: warning styling plus the re-run call to action for
      SCORING_FAILED, neutral note with no call to action for NO_CANDIDATES. Its
      heading comes from getEmptyRunTitle() instead of a hardcoded string.
    • The KPI score-card caption gets the same split, so both surfaces agree.
      OptimizationKPICards' scoringFailed boolean becomes emptyRunCause, since the
      old name was untrue for a candidate-less run.

    Wave-2 exact-count strings and the failed_count === 0 suppression are unchanged
    and pinned by tests.

    Addresses review feedback: getEmptyRunWarningMessage renamed to
    getEmptyRunMessage now that it also returns neutral copy, panel severity styling
    consolidated into one map, and the useMemo around the primitive cause dropped.

    Co-Authored-By: Claude Opus 5 (1M context) noreply@anthropic.com

    • [OPIK-7458] [FE] review: document the classifier's input bound, type the icon as LucideIcon
    • computeEmptyRunCause: note that candidates is the created_at-ascending page-1
      load capped at MAX_EXPERIMENTS_LOADED, so the baseline is always present and
      only trials past the cap can be missing. Also record why scoring_health cannot
      replace the candidate scan: its counts are per dataset item, so they cannot
      distinguish "no candidates generated" from "candidates failed to score".
    • EmptyRunWarningPanel: type the appearance icon as LucideIcon rather than
      typeof Info, matching stat-card and KPICard.

    Co-Authored-By: Claude Opus 5 (1M context) noreply@anthropic.com

    • [OPIK-7458] [FE] review: single-source the scoring-failure lead copy

    The panel body and KPI caption each re-derived the failure lead sentence
    (all-failed vs partial, noun agreement with total_count), so the two
    surfaces could drift apart. Extract summarizeScoringFailure() as the one
    place that classifies scoring_health and builds the lead; the callers
    only append their surface-specific tail.

    Co-Authored-By: Claude Fable 5 noreply@anthropic.com

    • [OPIK-7458] [FE] review: cut the over-explaining comments

    The comments had grown to a third of optimizationOverviewHelpers.ts, well
    past the ~6-9% of neighbouring files, and most of the bulk restated the
    code: a four-step numbered walkthrough of a nine-line classifier, per-member
    docs on self-describing enum members, a heading helper documented as
    returning a heading, and the same OPIK-7458 rationale repeated across the
    panel, the KPI card and their two call sites.

    Keep the rationale a reader cannot recover from the code: why the classifier
    takes candidates rather than scoring_health, the page-1 cap on that
    input, the noun-agreement rules in the count copy, why the backend's
    failed_count wins over the client classifier, why NO_CANDIDATES carries no
    call to action, and why SCORING_FAILED uses the warning rather than the
    destructive tokens. Drop the restatements.

    No behaviour change: 109 tests in src/v2/pages/OptimizationPage pass,
    typecheck and eslint clean.

    Co-Authored-By: Claude Opus 5 (1M context) noreply@anthropic.com


    Co-authored-by: Claude Opus 5 (1M context) noreply@anthropic.com

    下载附件