Skip to content

[AI] Fix clearing pre-assigned transaction fields - #7455

Closed
NathanDrake2406 wants to merge 4 commits into
actualbudget:masterfrom
NathanDrake2406:fix/clear-preassigned-category
Closed

NathanDrake2406 wants to merge 4 commits into
actualbudget:masterfrom
NathanDrake2406:fix/clear-preassigned-category

Conversation

@NathanDrake2406

@NathanDrake2406 NathanDrake2406 commented Apr 10, 2026 •

Copy link
Copy Markdown

Description

Fixes a bug where clearing a rule-populated field on a new transaction did not stick. If a payee rule pre-assigned a category, notes, or another empty-overwritable field, clearing that field would immediately get overwritten the next time rules ran.

This change extracts the merge logic from TransactionList into a pure helper and teaches it to preserve the field the user just edited, even when that edit clears the value. It also fixes the split-transaction case so clearing a field on the parent does not let rule output repopulate that field on child splits.

Related issue(s)

#7390

Testing

Unit tests:
Covered clearing a rule-assigned category on a normal transaction
Covered clearing notes
Covered initial-load behavior when updatedFieldName is null
Covered split propagation when a parent field is set
Covered split propagation when category or notes is cleared on the parent

Checklist

  • Release notes added (see link above)
  • No obvious regressions in affected areas
  • Self-review has been performed - I understand what each change in the code does and why it is needed

Bundle Stats

Bundle Files count Total bundle size % Changed
desktop-client 28 12.9 MB → 12.91 MB (+559 B) +0.00%
loot-core 1 4.84 MB 0%
api 1 3.88 MB 0%
cli 1 7.89 MB 0%
View detailed bundle stats

desktop-client

Total

Files count Total bundle size % Changed
28 12.9 MB → 12.91 MB (+559 B) +0.00%
Changeset
File Δ Size
src/components/transactions/applyRulesToTransaction.ts 🆕 +1.15 kB 0 B → 1.15 kB
src/components/transactions/TransactionList.tsx 📉 -619 B (-3.53%) 17.13 kB → 16.52 kB
View detailed bundle breakdown

Added
No assets were added

Removed
No assets were removed

Bigger

Asset File Size % Changed
static/js/Value.js 4.33 MB → 4.33 MB (+559 B) +0.01%

Smaller
No assets were smaller

Unchanged

Asset File Size % Changed
static/js/index.js 3.32 MB 0%
static/js/BackgroundImage.js 121.09 kB 0%
static/js/FormulaEditor.js 852.77 kB 0%
static/js/ReportRouter.js 1.17 MB 0%
static/js/TransactionList.js 82.49 kB 0%
static/js/ca.js 191.98 kB 0%
static/js/da.js 104.66 kB 0%
static/js/de.js 174.38 kB 0%
static/js/en-GB.js 8.2 kB 0%
static/js/en.js 175.89 kB 0%
static/js/es.js 181.8 kB 0%
static/js/extends.js 485.17 kB 0%
static/js/fr.js 177.08 kB 0%
static/js/indexeddb-main-thread-worker-e59fee74.js 13.46 kB 0%
static/js/it.js 165.95 kB 0%
static/js/narrow.js 363.02 kB 0%
static/js/nb-NO.js 151.85 kB 0%
static/js/nl.js 108.93 kB 0%
static/js/pl.js 88.34 kB 0%
static/js/pt-BR.js 177.44 kB 0%
static/js/resize-observer.js 18.06 kB 0%
static/js/th.js 179.3 kB 0%
static/js/theme.js 30.79 kB 0%
static/js/uk.js 212.6 kB 0%
static/js/wide.js 295 B 0%
static/js/workbox-window.prod.es5.js 7.33 kB 0%
static/js/zh-Hans.js 110.19 kB 0%

loot-core

Total

Files count Total bundle size % Changed
1 4.84 MB 0%
View detailed bundle breakdown

Added
No assets were added

Removed
No assets were removed

Bigger
No assets were bigger

Smaller
No assets were smaller

Unchanged

Asset File Size % Changed
kcab.worker.DZcmk4OR.js 4.84 MB 0%

api

Total

Files count Total bundle size % Changed
1 3.88 MB 0%
View detailed bundle breakdown

Added
No assets were added

Removed
No assets were removed

Bigger
No assets were bigger

Smaller
No assets were smaller

Unchanged

Asset File Size % Changed
index.js 3.88 MB 0%

cli

Total

Files count Total bundle size % Changed
1 7.89 MB 0%
View detailed bundle breakdown

Added
No assets were added

Removed
No assets were removed

Bigger
No assets were bigger

Smaller
No assets were smaller

Unchanged

Asset File Size % Changed
cli.js 7.89 MB 0%

@actual-github-bot actual-github-bot Bot changed the title [AI] Fix clearing pre-assigned transaction fields [WIP] [AI] Fix clearing pre-assigned transaction fields Apr 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

👋 Hello contributor!

We would love to review your PR! Before we can do that, please make sure:

  • ✅ All CI checks pass
  • ✅ The PR is moved from draft to open (if applicable)
  • ✅ The "[WIP]" prefix is removed from the PR title
  • ✅ All CodeRabbit code review comments are resolved (if you disagree with anything - reply to the bot with your reasoning so we can read through it). The bot will eventually approve the PR.

We do this to reduce the TOIL the core contributor team has to go through for each PR and to allow for speedy reviews and merges.

For more information, please see our Contributing Guide.

@netlify

netlify Bot commented Apr 10, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit 79a0785
🔍 Latest deploy log https://app.netlify.com/projects/actualbudget/deploys/69db3892229e4900082e9bf2
😎 Deploy Preview https://deploy-preview-7455.demo.actualbudget.org
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@NathanDrake2406 NathanDrake2406 changed the title [WIP] [AI] Fix clearing pre-assigned transaction fields [AI] Fix clearing pre-assigned transaction fields Apr 10, 2026
@coderabbitai

coderabbitai Bot commented Apr 10, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Refactors transaction rule-application logic into a new helper applyRulesToTransaction() that post-processes rule outputs to selectively apply changes, preserve explicit user edits, and propagate certain parent updates to subtransactions; adds unit tests and a release-note entry.

Changes

Cohort / File(s) Summary
TransactionList update
packages/desktop-client/src/components/transactions/TransactionList.tsx
Removed inline rules-result transformation from onApplyRules; now delegates to applyRulesToTransaction() and removed getChangedValues import.
New rule application module
packages/desktop-client/src/components/transactions/applyRulesToTransaction.ts
Added applyRulesToTransaction(transaction, afterRules, updatedFieldName) that computes diffs, writes rule values only into overwritable (empty/falsy) fields, preserves the explicitly updated field, and can propagate a parent-updated field into subtransactions when appropriate.
Tests for rule behavior
packages/desktop-client/src/components/transactions/applyRulesToTransaction.test.ts
New Vitest suite exercising empty-field population, user-cleared-field preservation, non-empty-field protection, initial-load behavior, and parent→subtransaction propagation semantics.
Release notes
upcoming-release-notes/7455.md
Adds release-note documenting that users can clear pre-assigned transaction fields without the rules engine immediately repopulating them.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐇 I nibbled at rules and set fields free,

When users say "clear", the rules let it be.
Parent hops, children follow with care,
Tests guard the burrow with tidy flair,
A carrot-coded change, light as a breeze.

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title '[AI] Fix clearing pre-assigned transaction fields' directly and clearly summarizes the main change—fixing a bug where users couldn't clear rule-populated fields on transactions.
Description check ✅ Passed The pull request description clearly explains the bug being fixed (clearing rule-populated fields not persisting), the solution approach (extracting merge logic into a helper that preserves user edits), and includes related issue reference and testing coverage details.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@packages/desktop-client/src/components/transactions/applyRulesToTransaction.test.ts`:
- Line 1: Remove the unnecessary import of Vitest globals by deleting the
"import { describe, expect, it } from 'vitest';" line in
applyRulesToTransaction.test.ts; since globals: true is enabled in the Vite
config the test should use describe/it/expect directly without importing them.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 23e3fd0e-2f4c-4e09-b065-ad883a0ab2c3

📥 Commits

Reviewing files that changed from the base of the PR and between 6a96231 and 5514b93.

📒 Files selected for processing (3)
  • packages/desktop-client/src/components/transactions/TransactionList.tsx
  • packages/desktop-client/src/components/transactions/applyRulesToTransaction.test.ts
  • packages/desktop-client/src/components/transactions/applyRulesToTransaction.ts

coderabbitai[bot]
coderabbitai Bot previously approved these changes Apr 10, 2026
@saydmateen

Copy link
Copy Markdown

The /mobile - TransactionEdit looks to have the same bug. Not sure if that is going to be updated separately but thought to call it out.

@gemivnet

Copy link
Copy Markdown

Thank you so much! Excited to see this fix get merged and released!

@github-actions

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions Bot added the Stale label May 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR was closed because it has been stalled for 5 days with no activity.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants