Skip to content

fix(console): name the history window when a range has no records - #1009

Merged
Pigbibi merged 1 commit into
mainfrom
fix/console-history-window-label-20261101
Oct 31, 2026
Merged

Pigbibi merged 1 commit into
mainfrom
fix/console-history-window-label-20261101

Conversation

@Pigbibi

@Pigbibi Pigbibi commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

AI assistance

Qoder Desktop agent (AI-assisted); the change was read back as a diff and run through the repository checks below.

What changed

The live console withholds every combined metric for ibkr:tqqq at range=YTD (status: partial, unavailable_reason: snapshot_history_missing), and the single summary note said only Partial · Data as of 2026-10-29 while the six KPI cards read Unavailable. That reads like a broken pipeline. The cause is a date fact the API already publishes: stored native history for this account begins 2026-09-25 (soxl: 2026-10-26), so a YTD range contains no requested-day record at all, while 1M and ALL on the same account return real numbers (1M TWR -6.4169%, P/L -17.3507 USD, max drawdown 10.0098%).

application/console_api/native_daily_returns.js:107-109 emits period_from, period_to, requested_period_from and range_complete on the summary coverage; the frontend ignored them. This PR consumes them and states the shortfall window in the existing note, keeping every total withheld exactly as before.

  • frontend/src/api/contracts.ts: the four coverage fields are now typed on PerformanceCoverage.
  • frontend/src/pages/performance/SummaryCards.tsx: the note gains a third branch. It claims a short history only when the summary is blank and range_complete === false and period_from > requested_period_from, i.e. stored records start after the requested start. A trailing gap (range_complete === false with an in-range start) and range=ALL (requested_period_from is set to period_from) fall through to the previous copy. fxNotApplied was re-derived from the same narrowed coverageDetail guard; its behaviour is unchanged.
  • frontend/src/i18n/pages/performance.ts: perf.history_window_short in both locales; dates use formatDate, so the sentence follows the existing locale/date conventions.
  • tests/console_display_gaps_validation.mjs: renders the production SummaryCards for a short-history summary and asserts one shared note, both dates present, and no digit in any kpi-value (an explained blank is still a blank, no invented total), plus three negative cases that must not claim a shortfall.
  • web/strategy-switch-console/v2_asset_map.js: regenerated committed bundle (npm run build && npm run sync:v2-assets), build id 05b365cb526eafe20dc58cb30f4133d3304b2b9680b60fce75d29148f46e6ab4.

No read contract, refusal rule, metric value or aggregation changed: this is display-only. Nothing here closes a data gap — the YTD totals stay unavailable until the history is backfilled or the range grows past the stored start.

How verified

  • npm run build --prefix web/strategy-switch-console/frontend — TypeScript check, Vite build, size budget OK.
  • npm run sync:v2-assets --prefix web/strategy-switch-console/frontend — generated 26 v2 assets (845912 bytes source); node tests/console_v2_assets_validation.mjs PASS (76 references; 26 assets served).
  • node tests/console_v2_i18n_validation.mjs — PASS (1416 locale entries); the new key and both localized sentences are present in the decoded bundle (index-Ch0GFvXa.js).
  • node tests/console_display_gaps_validation.mjs — PASS, including the new short-history assertions in both languages.
  • npm run test:operations --prefix web/strategy-switch-console/frontend — exit 0, all suites PASS, including native_daily_gap_ui_validation and console_shell_unavailable_source_ui_validation.
  • node tests/console_presentation_validation.mjs, console_v2_worker_validation.mjs — PASS.
  • Not run: the Python suite, the deploy workflow and the live console (the bundle is regenerated, so validate.yml's git diff --exit-code -- web/strategy-switch-console/v2_asset_map.js gate is expected to hold; live verification happens after merge and deploy).

Summary by CodeRabbit

  • New Features
    • Performance summaries now explain when the selected date range starts before available history, showing both the requested and available start dates in the current language.
    • Totals remain blank for incomplete ranges with insufficient history.

A YTD scope whose stored native history starts in September read as a bare
"Unavailable", which looks like a broken pipeline rather than a short
history. The summary already publishes range_complete, period_from and
requested_period_from, so state the shortfall window and keep every total
withheld exactly as before.
@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5b928385-26e6-4e3f-8bc9-d974b6755f0f
Commits

Reviewing files that changed from the base of the PR and between 8a3ac12 and 40832be.

Files selected for processing: 5
  • tests/console_display_gaps_validation.mjs
  • web/strategy-switch-console/frontend/src/api/contracts.ts
  • web/strategy-switch-console/frontend/src/i18n/pages/performance.ts
  • web/strategy-switch-console/frontend/src/pages/performance/SummaryCards.tsx
  • web/strategy-switch-console/v2_asset_map.js

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

Performance coverage now exposes stored and requested period metadata. When the summary is blank and the requested range starts before stored history, SummaryCards displays a localized message with both dates. Tests cover both languages and conditions where the message is absent.

Changes: Short-history coverage message

Layer / File(s) Summary
Coverage metadata and localized summary display
web/strategy-switch-console/frontend/src/api/contracts.ts, web/strategy-switch-console/frontend/src/i18n/pages/performance.ts, web/strategy-switch-console/frontend/src/pages/performance/SummaryCards.tsx, tests/console_display_gaps_validation.mjs
PerformanceCoverage adds stored and requested period fields and a range-completeness flag. For a blank summary, SummaryCards shows a localized message with the requested and available start dates when the requested range is incomplete and begins before stored history. Tests cover Chinese and English text, blank KPI values, and conditions that suppress the message.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: Minimal · up to 40832

The new note explains short history while keeping unavailable totals blank. No material merge risk was identified.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: naming the history window when the selected range has no records.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 4 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@Pigbibi

Pigbibi commented Oct 31, 2026

Copy link
Copy Markdown
Contributor Author

CodeRabbit audit record

Automatic reviews are skipped for this repository (fewer than 10 stars), so the review was triggered through the CodeRabbit checkbox comment rather than waiting for it.

  • Inline review comments: 0. The review comment states: No actionable comments were generated in the recent review.
  • Pre-merge checks: Title check passed; Description / Linked Issues / Out-of-Scope checks skipped (summary mode, no linked issues). The single warning is Docstring coverage is 0.00% over the 1 touched function with cyclomatic complexity >= 2 (SummaryCards). This repo has no JSDoc-on-components convention, and the same warning was present on the merged feat(console): render the external-flow switch from the deploy Environment #1007 and fix(console): surface unreadable to-do count and account metadata #1008, so it is not treated as a blocking finding here.
  • GitHub checks: validate, js, python, actionlint, pinned-producer-roundtrip, Commit message convention, Documentation check, Gitleaks, pr-template all pass, including the git diff --exit-code -- web/strategy-switch-console/v2_asset_map.js bundle gate. Only risk-gate / Evaluate PR governance fail, which is the expected high-risk-path state until owner-approved is applied.

Per the agreed governance rule (clean CodeRabbit audit -> approve, otherwise fix first), the audit is clean on actionable findings, so the owner approval label is applied and the merge proceeds.

@Pigbibi Pigbibi added the owner-approved Owner approval for high-risk PRs. AI agents must never apply this label. label Oct 31, 2026
@Pigbibi
Pigbibi merged commit d52804a into main Oct 31, 2026
16 of 18 checks passed
@Pigbibi
Pigbibi deleted the fix/console-history-window-label-20261101 branch October 31, 2026 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

owner-approved Owner approval for high-risk PRs. AI agents must never apply this label.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant