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 -->