Skip to content

fix(forecast-panel): theater card conf=0, scenario type badges, sorted paths#2443

Merged
koala73 merged 1 commit intomainfrom
fix/forecast-panel-theater-ux
Mar 28, 2026
Merged

fix(forecast-panel): theater card conf=0, scenario type badges, sorted paths#2443
koala73 merged 1 commit intomainfrom
fix/forecast-panel-theater-ux

Conversation

@koala73
Copy link
Copy Markdown
Owner

@koala73 koala73 commented Mar 28, 2026

Summary

  • conf=0 LLM anchor: Round 2 prompt used "confidence": 0.0 as placeholder in JSON example. LLMs copy placeholder values verbatim, causing all path gauges to show 0%. Replaced with representative values (0.35/0.50/0.15 for escalation/containment/market_cascade).
  • Sort by confidence: topPaths[0] (the dominant path in the theater card gauge) was LLM output order. Cards could show the least-likely scenario as dominant. Now sorted descending before slice.
  • Scenario type badges: pathId was stripped from uiTheaters Redis output. Added it back; added colour-coded fc-path-type badges (escalation red / containment green / market_cascade amber) to both theater card summary line and path cards in the detail view.
  • conf=0 guard: Gauge label and path confidence text show instead of 0% when confidence is zero, covering existing Redis data until next simulation run.

Test plan

  • Theater cards show highest-confidence path in gauge, not first LLM output
  • Theater with previously-zero confidence shows in gauge (existing Redis data) then real values after next simulation run
  • Expand a theater card: each path card shows coloured scenario badge (Escalation / Containment / Market Cascade)
  • Typecheck passes

…d paths

Three related UX fixes in the simulation NEXUS theater display:

1. conf=0 prompt fix (seed-forecasts.mjs): Round 2 prompt used "confidence": 0.0
   as placeholder values in the JSON example. LLMs copy placeholder values verbatim
   when uncertain, causing all three paths to emit confidence=0 and the gauge to
   show '0%'. Replace with representative values (0.35/0.50/0.15 for
   escalation/containment/market_cascade) to anchor the LLM.

2. Sort topPaths by confidence descending (seed-forecasts.mjs): topPaths[0] (the
   dominant path shown in the theater card gauge) was ordered by LLM output position,
   not by confidence. The card could display the lowest-confidence scenario as dominant.
   Sort before slicing so the card always shows the most confident scenario.

3. pathId exposed + scenario type badges (ForecastPanel.ts): pathId was stripped from
   uiTheaters output, making it impossible to show scenario type in the UI. Expose
   pathId in uiTheaters map. Add PATH_ID_LABELS and fc-path-type CSS badges coloured
   by scenario type (escalation=red, containment=green, market_cascade=amber).
   Add badge to both the theater card summary line and each path card in the detail view.
   Guard gauge label and conf text: show '—' instead of '0%' when confidence is 0.
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 28, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
worldmonitor Ignored Ignored Mar 28, 2026 5:48pm

Request Review

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Mar 28, 2026

Greptile Summary

This PR fixes four related bugs in the ForecastPanel theater card feature: LLM placeholder confidence: 0.0 values being copied verbatim by the model, unsorted topPaths causing the least-likely scenario to appear dominant, missing pathId in the Redis uiTheaters payload, and the absence of a zero-confidence guard in the UI.

Key changes:

  • seed-forecasts.mjs: Replaces 0.0 placeholder confidences in the Round 2 LLM prompt with representative values (0.35 / 0.50 / 0.15) that sum to 1 and signal proportional intent; adds pathId to the Redis-mapped path object; sorts topPaths descending by confidence before slicing to 3.
  • ForecastPanel.ts: Adds PATH_ID_LABELS map and pathId to the SimulationPath interface; introduces colour-coded fc-path-type badges (red/green/amber) rendered in both the theater card summary line and the detail path cards; guards the gauge label and path confidence text to show instead of 0% when confidence === 0.
  • The zero-confidence guard handles existing Redis data transparently until the next simulation run repopulates with corrected values.

Confidence Score: 5/5

Safe to merge — all remaining findings are minor style/defensive-coding suggestions with no impact on correctness or runtime behaviour.

Both changes are well-scoped and self-contained. The zero-confidence guard, badge rendering, and sort are all correct. The only issues found are a P2 in-place mutation of the input array (harmless in the current call flow because R2 is written before the sort runs) and a P2 defensive-coding note about using an allow-list when interpolating pathId into CSS class names. Neither blocks merge.

No files require special attention — both files have only minor P2 suggestions.

Important Files Changed

Filename Overview
scripts/seed-forecasts.mjs Fixes LLM prompt placeholders (0.0 → representative values), adds confidence-sorted topPaths, and surfaces pathId in the Redis uiTheaters payload; sort mutates the original topPaths array (minor side-effect).
src/components/ForecastPanel.ts Adds PATH_ID_LABELS map, pathId to SimulationPath, colour-coded fc-path-type badges in theater card and detail view, and a conf=0 guard that renders — instead of 0% in the gauge and path confidence text.

Sequence Diagram

sequenceDiagram
    participant LLM as LLM (Round 2)
    participant Seed as seed-forecasts.mjs
    participant R2 as R2 Storage
    participant Redis as Redis (uiTheaters)
    participant UI as ForecastPanel.ts

    LLM->>Seed: topPaths[] with representative confidences (0.35/0.50/0.15)
    Seed->>R2: putR2JsonObject(outcome) — original LLM order
    Seed->>Seed: sort topPaths desc by confidence
    Seed->>Seed: slice(0,3) + map (adds pathId)
    Seed->>Redis: SET uiTheaters (sorted, with pathId)

    UI->>Redis: fetch uiTheaters JSON
    Redis-->>UI: SimulationTheater[] (topPaths[0] = highest confidence)
    UI->>UI: renderTheaterCard → gauge shows topPaths[0].confidence
    UI->>UI: conf > 0 ? "X%" : "—"
    UI->>UI: pathId → fc-path-type badge (escalation/containment/market_cascade)
Loading

Reviews (1): Last reviewed commit: "fix(forecast-panel): theater card conf=0..." | Re-trigger Greptile

@koala73 koala73 merged commit d9c7cdd into main Mar 28, 2026
8 checks passed
@koala73 koala73 deleted the fix/forecast-panel-theater-ux branch March 28, 2026 17:58
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.

1 participant