Repository navigation
fix(console): name the history window when a range has no records - #1009
Conversation
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.
|
No actionable comments were generated in the recent review.
|
| 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: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passedFull 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.
CodeRabbit audit recordAutomatic 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.
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. |
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:tqqqatrange=YTD(status: partial,unavailable_reason: snapshot_history_missing), and the single summary note said onlyPartial · Data as of 2026-10-29while the six KPI cards readUnavailable. That reads like a broken pipeline. The cause is a date fact the API already publishes: stored native history for this account begins2026-09-25(soxl: 2026-10-26), so a YTD range contains no requested-day record at all, while1MandALLon the same account return real numbers (1MTWR -6.4169%, P/L -17.3507 USD, max drawdown 10.0098%).application/console_api/native_daily_returns.js:107-109emitsperiod_from,period_to,requested_period_fromandrange_completeon 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 onPerformanceCoverage.frontend/src/pages/performance/SummaryCards.tsx: the note gains a third branch. It claims a short history only when the summary is blank andrange_complete === falseandperiod_from > requested_period_from, i.e. stored records start after the requested start. A trailing gap (range_complete === falsewith an in-range start) andrange=ALL(requested_period_fromis set toperiod_from) fall through to the previous copy.fxNotAppliedwas re-derived from the same narrowedcoverageDetailguard; its behaviour is unchanged.frontend/src/i18n/pages/performance.ts:perf.history_window_shortin both locales; dates useformatDate, so the sentence follows the existing locale/date conventions.tests/console_display_gaps_validation.mjs: renders the productionSummaryCardsfor a short-history summary and asserts one shared note, both dates present, and no digit in anykpi-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 id05b365cb526eafe20dc58cb30f4133d3304b2b9680b60fce75d29148f46e6ab4.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.mjsPASS (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, includingnative_daily_gap_ui_validationandconsole_shell_unavailable_source_ui_validation.node tests/console_presentation_validation.mjs,console_v2_worker_validation.mjs— PASS.validate.yml'sgit diff --exit-code -- web/strategy-switch-console/v2_asset_map.jsgate is expected to hold; live verification happens after merge and deploy).Summary by CodeRabbit