Repository navigation
feat(chart): add investment progression chart to simulation - #597
Conversation
Sample the net value of each simulated investment over time (CDB net of IR/IOF, Poupança and LCI/LCA exempt) in a new pure getNetProgression() module, and render it as a theme-aware line chart above the result cards. The chart reads its palette from Tailwind v4 CSS variables so dark mode and future palette changes restyle the canvas, and it waits for a real 2D canvas before mounting Chart.js so DOM-less test environments keep working. vue-chartjs is pinned to 5.3.7: the 5.3.6 tarball on the registry ships without dist/index.js/index.cjs, so pnpm's minimum release age is bypassed for it.
Address code-review findings: - move chart presentation helpers to app/lib/chart.ts, keeping app/src for the pure financial logic documented in AGENTS.md - sample progression points at monthly marks for typical durations instead of a fixed 10-day step - pin the early-redemption semantics with tests: IOF inside the 30-day window, none at day 30, and each point using its own IR bracket
- correct the ProgressionPoint type import in app/lib/chart.ts and the possibly-undefined regex capture in parseHexColor (tsc --noEmit is clean for app sources again) - plot progression points on a linear day axis so uneven sample intervals keep true time proportions instead of equal-width categories - tighten the endpoint invariant tests to exact equality with the result-card values
Close the retro findings: - add tsconfig.typecheck.json (app/src + app/lib only) with a pnpm typecheck script, wired into CI between lint and test; full-project tsc stays dirty with pre-existing test typings, so the guardrail is scoped - document the happy-dom canvas gate for canvas-based components and the pnpm minimumReleaseAge pin/exclude workflow in AGENTS.md
Vite discovered chart.js and vue-chartjs at runtime on the first page load, invalidating the optimized-dep hashes mid-flight: the browser's module imports then failed (Importing a module script failed, cascading into an undefined head.push), leaving the SPA broken on first load. Adding both to vite.optimizeDeps.include pre-bundles them at server start. Verified by walking the whole dev-server module graph from the SPA entry: 265 modules, zero non-200 responses on a cold start with a cleared Vite cache, and no runtime dependency discovery.
nuxt-schema-org 7.0.1 ships a reactive client init plugin when ssr is false. Nuxt 4.6.4's injectHead silently returns undefined in the SPA plugin context, so the plugin's head.push throws on app boot and Safari reports "undefined is not an object (evaluating 'head.push')" — the dev server has been unusable since the dependency bump in #596. Remove the module: it requires SSR to add SEO value, this site is a static SPA, so its client-side graph was invisible to crawlers and unused by app code. Drop the site block and the @unhead/schema-org/vue optimizeDeps entry along with it. Add "type": "module" to package.json to stop Node re-parsing nuxt.config.ts on every dev/test run (MODULE_TYPELESS_PACKAGE_JSON warning). Verified: cold dev start with no warnings or errors, module-graph walk of 253 modules with zero failures and no schema-org modules served, lint, typecheck, 124 tests, generate.
- spread the five series across distinct hues: CDB/RDB pre moves from emerald to rose, LCI/LCA from violet to teal, LCI/LCA pre from indigo to violet (amber/sky unchanged) - render every series as a line-only trace (fill: false) instead of 8%-alpha filled areas; drop the now-unused withAlpha/parseHexColor - pin the day axis to the simulated period (min 0, max = last sampled day) so Chart.js no longer pads the right side with empty space
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
…a" (#598) ## Summary The site is a client-only SPA (`ssr: false`): every `useSeoMeta` call ran in the browser, so scrapers saw no description, no og:image, no canonical, no JSON-LD — and the hand-maintained `sitemap.xml` was already missing `/como-calcular-imposto-de-renda`. This PR makes the whole site prerendered and hands SEO generation to `@nuxtjs/seo`: ```diff nuxt.config.ts - ssr: false + ssr: true // runs at build time only — `nuxi generate` emits static HTML + modules: [ '@nuxtjs/seo' ] + site: { url, name, description, trailingSlash } + routeRules: ogImage per page // rendered at build from app/components/OgImage/Main.satori.vue ``` - Per-page `useSeoMeta` (title/description/twitter card) + `useSchemaOrg` (SoftwareApplication on home, FAQPage + BreadcrumbList on guides) - Sitemap, robots.txt, canonicals, `og:image` PNGs, `_headers`/skew-protection assets — all generated at build; hand-maintained `public/sitemap.xml` deleted - Visible "Perguntas frequentes" sections on both guides, matching the FAQPage JSON-LD exactly - `pnpm verify:seo` (35 checks over `.output/public`) wired into CI and publish, so the generate step can never silently regress - AGENTS.md updated for the prerendered world About #597: that PR removed `nuxt-schema-org` because under `ssr: false` its SPA plugin crashed the dev server and its graph was client-only. Both reasons dissolve under `ssr: true` — the module is back as part of `@nuxtjs/seo`, and the dev server boots clean. ## Evidence - **Before:** `curl https://rendafixa.github.io` → no `<meta name="description">`, no `og:*`, no JSON-LD in served HTML; sitemap missing one of four pages. **After:** every page ships title/description/canonical/og:image/twitter card in the static HTML; `pnpm verify:seo` passes all 35 checks (titles, lang, canonicals, og:image PNG existence, JSON-LD types, FAQ questions visible in markup, 4 sitemap locs, robots); `pnpm test` → 133 passed; `pnpm generate` clean with no dev warnings. ## Merge Danger **Door:** two-way — pure build-output change, hosting (GitHub Pages static) untouched, `git revert` restores the SPA. **Blast Radius:** site-wide rendering — pages now render server-side, so anything assuming browser-only setup would break at build time (generate + tests cover all four pages). Post-deploy, the og:image PNGs need a human eyeball, and Search Console should get the resubmitted sitemap + indexing request. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * Added FAQs about income tax, IOF, and savings-account interest to the relevant guides. * Added social sharing images and structured page information across the main pages, with richer search-result details. * **Improvements** * Updated the site title and description to reflect the calculator and its supported investments. * The full site title now appears in the header on small screens. * Updated guide links to use consistent trailing slashes. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Summary
Adds a Chart.js line chart comparing the net progression of Poupança, CDB/RDB, CDB/RDB pré, LCI/LCA and LCI/LCA pré over the simulated period, then refines its presentation after a visual review:
The x-axis
maxmatters: without it Chart.js rounds the linear scale up to the next "nice" number past the period (e.g. 720 days renders out to 800), leaving dead space on the right.Stack context: beyond the chart feature itself (
4b0dc54), the branch carries the dev-server pre-bundling and ESM fixes needed to run it (0474bd9,6f1256e) and the scoped typecheck guardrail (2c77cc0).Evidence
Before: chart.spec asserted
fill: truewith a tintedbackgroundColor, and the x-axis had no bounds —x.min/x.maxwereundefined.After: chart.spec asserts every dataset has
fill: falseand nobackgroundColor, and pinsx.min === 0/x.max === maxDay(10/10 intest/unit/lib/chart.spec.ts).Full CI order passes locally:
pnpm lint→pnpm typecheck→ full suite 125/125 →pnpm generate.Visual change — worth an eyeball in both light and dark themes before merge; the new rose/teal/violet hues were chosen for separation including common color-blindness.
Merge Danger
Door: two-way
Pure presentation change; revert restores the filled-area chart.
Blast Radius: chart display only
No financial logic touched (
app/srcuntouched);buildProgressionOptionscallers are all updated in the same branch.Summary by CodeRabbit