Skip to content

feat(ai): add bulk record_activities tool for AI assistant#661

Open
kwaich wants to merge 2 commits intoafadil:mainfrom
kwaich:feature/ai_record_activities
Open

feat(ai): add bulk record_activities tool for AI assistant#661
kwaich wants to merge 2 commits intoafadil:mainfrom
kwaich:feature/ai_record_activities

Conversation

@kwaich
Copy link
Contributor

@kwaich kwaich commented Mar 4, 2026

Description

Adds a new record_activities AI tool that allows the assistant to record multiple investment activities in a single interaction, complementing the existing single-activity record_activity tool.

Changes:

  • Backend (Rust): New record_activities tool with batch save logic; registers in tool registry, chat.rs, and system prompt
  • Frontend: New RecordActivitiesToolUI with per-row status tracking, confirm flow, and error display
  • Shared utils: Extracted activity table formatters (shared/activity-table-utils.ts) to eliminate duplication between the search and record UIs
  • Tests: Unit tests for record-activities-tool-utils.ts

Checklist

By submitting this PR, I agree to the CLA.

kwaich added 2 commits March 4, 2026 23:52
Introduces a new `record_activities` AI tool that allows recording
multiple investment activities at once, complementing the existing
single-activity `record_activity` tool.

- Add `record_activities` Rust tool with batch save logic
- Add `RecordActivitiesToolUI` with per-row status tracking and
  confirm/cancel flow
- Extract shared activity table formatters into `shared/activity-table-utils.ts`
  to eliminate duplication between search and record UIs
- Add utils + unit tests in `record-activities-tool-utils.ts`
- Register the new tool in chat shell, tool index, and system prompt
…eleton and RecordActivitiesToolUIContent functions
@afadil
Copy link
Owner

afadil commented Mar 4, 2026

Hi, wondering if it's better re-use the exisiting csv import and adapt it for both bulk record and import.

@kwaich
Copy link
Contributor Author

kwaich commented Mar 5, 2026

Hi @afadil, good question. I looked at both paths before deciding to keep them separate.

Both tools share the same save path (saveActivities()bulk_mutate_activities()), but their input processing is quite different.

Input shape mismatch

  • import_csv starts with raw CSV bytes and does a lot of heavy lifting: parsing headers, auto-detecting field mappings, normalizing dates/numbers/activity types, and building CsvActivityDraft rows.
  • record_activities receives pre-structured LLM args and builds ActivityDraft rows directly, no parsing needed.

Forcing one through the other's pipeline would either break import_csv by stripping out its parsing logic, or add unnecessary overhead to record_activities.

Intermediate model mismatch

  • CsvActivityDraft carries CSV-specific fields like row_number, raw_values, errors[], warnings[], applied_mapping, cleaning_actions, and detected_headers.
  • ActivityDraft carries AI-specific fields like price_source, is_custom_asset, pricing_mode, and asset_kind.

Unifying them would mean populating irrelevant fields with dummy values on both sides, which feels like the wrong tradeoff.

The shared layer already exists
Both paths converge at saveActivities()bulk_mutate_activities()prepare_activities_for_save() → repository, which I think is the right abstraction boundary.

That said, I'd love to hear your thoughts if you see it differently. There may be angles I haven't considered!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants