Add savings chat analysis feature

This commit is contained in:
Matthias
2026-06-15 18:26:25 +02:00
parent d65e7681ac
commit 4869402d45
26 changed files with 2789 additions and 163 deletions

View File

@@ -0,0 +1,63 @@
---
id: TASK-1
title: Add complete chat transaction context
status: In Progress
assignee: []
created_date: '2026-06-15 13:52'
updated_date: '2026-06-15 14:02'
labels: []
dependencies: []
priority: high
ordinal: 1000
---
## Description
<!-- SECTION:DESCRIPTION:BEGIN -->
Make the savings chat evaluate every transaction matching the selected date range, account, and basis instead of silently sampling 150/300 rows. This includes exact context totals, a full prompt context for the AI action, and regression coverage for large transaction windows.
<!-- SECTION:DESCRIPTION:END -->
## Acceptance Criteria
<!-- AC:BEGIN -->
- [x] #1 Chat context totals count all matching transactions in the selected range, including more than 400 rows
- [x] #2 Account filtering is applied before counting and summing transactions
- [x] #3 The chat action no longer accepts or passes maxTransactions and reports the complete transaction count
- [x] #4 The frontend no longer passes maxTransactions and continues to show exact totals
- [x] #5 Regression tests, lint, and build verification pass or documented blockers are reported
<!-- AC:END -->
## Implementation Plan
<!-- SECTION:PLAN:BEGIN -->
1. Add Convex test dependencies and Vitest edge-runtime config
2. Write failing convex-test regression for 450 chat transactions and account filtering
3. Refactor savingsChat backend to remove maxTransactions and use indexed full scans
4. Update schema indexes for account+basis filters
5. Remove frontend maxTransactions arguments
6. Run focused test, lint, and build verification
7. Record verification notes and leave task In Progress pending user confirmation
<!-- SECTION:PLAN:END -->
## Implementation Notes
<!-- SECTION:NOTES:BEGIN -->
RED verified: npx vitest convex/savingsChat.test.ts --run fails because getContext does not return isComplete and still uses limited context shape.
Verification:
- PASS npx vitest convex/savingsChat.test.ts --run
- PASS npm run build
- PASS npx eslint convex/savingsChat.ts convex/savingsChat.test.ts src/pages/SavingsChatPage.tsx vitest.config.ts
- BLOCKED npm run lint still fails on pre-existing/unrelated files: convex/bank/comdirectProvider.ts, convex/bank/config.ts, src/components/import/TanAwaitDialog.tsx, layout/UI fast-refresh exports, SettingsPage.tsx, and related existing warnings. SavingsChatPage is no longer in the lint output.
Review fix:
- Added effective-basis fallback for legacy transactions without effectiveMonth by reading bookingDate range and including only rows where effectiveMonth is undefined.
- Added prompt-context regression coverage via internal.savingsChat.getPromptContext.
- PASS npx vitest convex/savingsChat.test.ts --run (2 tests)
- PASS npm run build
- PASS npx eslint convex/savingsChat.ts convex/savingsChat.test.ts src/pages/SavingsChatPage.tsx vitest.config.ts
Final review:
- Subagent re-review found no remaining correctness/spec issues.
- Prior blocker resolved: effective-basis loading now includes rows without effectiveMonth via bookingDate fallback queries.
- Fresh full npm run lint still fails only on unrelated existing files; no SavingsChatPage issue remains.
<!-- SECTION:NOTES:END -->

View File

@@ -0,0 +1,62 @@
---
id: TASK-2
title: Render category expense chart values as positive slices
status: In Progress
assignee: []
created_date: '2026-06-15 14:34'
updated_date: '2026-06-15 14:48'
labels: []
dependencies: []
priority: high
ordinal: 2000
---
## Description
<!-- SECTION:DESCRIPTION:BEGIN -->
Fix the dashboard category expense pie chart so negative expense totals render as visible pie slices while preserving expense-style formatting in the UI.
<!-- SECTION:DESCRIPTION:END -->
## Acceptance Criteria
<!-- AC:BEGIN -->
- [x] #1 Category breakdown pie renders visible slices for negative expense totals
- [x] #2 Tooltip still displays expense values with the existing currency formatting
- [x] #3 Build or focused verification passes, or blockers are documented
<!-- AC:END -->
## Implementation Plan
<!-- SECTION:PLAN:BEGIN -->
1. Normalize category breakdown values for chart rendering
2. Keep tooltip currency formatting consistent with expense values
3. Run focused build/type verification
4. Record verification notes and leave task In Progress pending user confirmation
<!-- SECTION:PLAN:END -->
## Implementation Notes
<!-- SECTION:NOTES:BEGIN -->
RED verified: npx vitest src/components/charts/CategoryBreakdownChart.test.ts --run fails because toCategoryPieData is missing.
Implemented category pie normalization via src/components/charts/categoryBreakdownData.ts and wired CategoryBreakdownChart to use chartAmount for Recharts while formatting tooltip values from the original signed amount.
Verification:
- PASS npx vitest src/components/charts/CategoryBreakdownChart.test.ts --run
- PASS npx eslint src/components/charts/CategoryBreakdownChart.tsx src/components/charts/CategoryBreakdownChart.test.ts src/components/charts/categoryBreakdownData.ts vitest.config.ts
- PASS npm run build
Note: npm run build still emits the existing Vite chunk-size warning for the main bundle.
Manual browser verification not completed in-agent because the in-app Browser target iab is unavailable in this session. Vite dev server is running at http://127.0.0.1:5173/ for user verification.
User requested readability improvement: place the pie chart on the left and category list on the right instead of using the crowded default legend below the chart.
Layout update: replaced the crowded Recharts category legend and slice labels with a responsive two-column layout: pie chart on the left, scrollable category list with swatches, signed amounts, and percentage shares on the right. Added stable min dimensions for the chart container after Vite logged Recharts container-size warnings during HMR.
Verification after layout update:
- PASS npx vitest src/components/charts/CategoryBreakdownChart.test.ts --run
- PASS npx eslint src/components/charts/CategoryBreakdownChart.tsx src/components/charts/CategoryBreakdownChart.test.ts src/components/charts/categoryBreakdownData.ts vitest.config.ts
- PASS npm run build
Note: npm run build still emits the existing Vite chunk-size warning for the main bundle.
<!-- SECTION:NOTES:END -->