Skip to content

[AI] Fix append notes rules on new transactions - #8003

Closed
kikiminyes wants to merge 1 commit into
actualbudget:masterfrom
kikiminyes:fix-append-notes-rule-new-transactions
Closed

kikiminyes wants to merge 1 commit into
actualbudget:masterfrom
kikiminyes:fix-append-notes-rule-new-transactions

Conversation

@kikiminyes

@kikiminyes kikiminyes commented May 31, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #7303

Summary

  • centralize how rule diffs are applied to new transactions
  • allow append/prepend notes rule results to update non-empty notes when they preserve the user-entered note
  • reuse the same rule-diff behavior for desktop and mobile transaction entry

Testing

  • corepack yarn workspace @actual-app/web test src/components/transactions/applyRuleDiff.test.ts
  • corepack yarn workspace @actual-app/web typecheck
  • corepack yarn oxfmt --check packages/desktop-client/package.json packages/desktop-client/src/components/transactions/applyRuleDiff.ts packages/desktop-client/src/components/transactions/applyRuleDiff.test.ts packages/desktop-client/src/components/transactions/TransactionList.tsx packages/desktop-client/src/components/mobile/transactions/TransactionEdit.tsx upcoming-release-notes/8003.md
  • corepack yarn oxlint --type-aware packages/desktop-client/src/components/transactions/applyRuleDiff.ts packages/desktop-client/src/components/transactions/applyRuleDiff.test.ts packages/desktop-client/src/components/transactions/TransactionList.tsx packages/desktop-client/src/components/mobile/transactions/TransactionEdit.tsx (0 errors; existing no-unsafe-type-assertion warnings remain in touched files)
  • PR_NUMBER=8003 node packages\ci-actions\bin\release-notes-check.mjs

Bundle Stats

Bundle Files count Total bundle size % Changed
desktop-client 37 14.03 MB ? 14.03 MB (+1.83 kB) +0.01%
loot-core 1 5.34 MB 0%
api 2 3.97 MB 0%
cli 1 7.97 MB 0%
crdt 1 11.12 kB 0%
View detailed bundle stats

desktop-client

Total

Files count Total bundle size % Changed
37 14.03 MB ? 14.03 MB (+1.83 kB) +0.01%
Changeset
File ? Size
src/components/transactions/applyRuleDiff.ts ?? +1.8 kB 0 B ? 1.8 kB
package.json ?? +93 B (+0.98%) 9.28 kB ? 9.38 kB
locale/en.json ?? +252 B (+0.12%) 198.24 kB ? 198.48 kB
src/components/mobile/transactions/TransactionEdit.tsx ?? -159 B (-0.22%) 71.47 kB ? 71.32 kB
src/components/transactions/TransactionList.tsx ?? -151 B (-0.85%) 17.29 kB ? 17.14 kB
View detailed bundle breakdown

Added
No assets were added

Removed
No assets were removed

Bigger

Asset File Size % Changed
static/js/Value.js 5.08 MB ? 5.08 MB (+1.65 kB) +0.03%
static/js/en.js 198.24 kB ? 198.48 kB (+252 B) +0.12%
static/js/index.js 1.54 MB ? 1.54 MB (+93 B) +0.01%

Smaller

Asset File Size % Changed
static/js/TransactionEdit.js 90.63 kB ? 90.47 kB (-159 B) -0.17%

Unchanged

Asset File Size % Changed
static/js/BackgroundImage.js 121.09 kB 0%
static/js/FormulaEditor.js 962.55 kB 0%
static/js/ManageRules.js 46.98 kB 0%
static/js/PayeeRuleCountLabel.js 7.33 kB 0%
static/js/ReportRouter.js 1.26 MB 0%
static/js/ScheduleEditForm.js 146.44 kB 0%
static/js/SchedulesTable.js 202.7 kB 0%
static/js/TransactionList.js 85.81 kB 0%
static/js/_baseIsEqual.js 98.38 kB 0%
static/js/ca.js 186.75 kB 0%
static/js/client.js 451.37 kB 0%
static/js/da.js 101.15 kB 0%
static/js/de.js 170.77 kB 0%
static/js/en-GB.js 9.25 kB 0%
static/js/es.js 178.68 kB 0%
static/js/extends.js 500.96 kB 0%
static/js/fr.js 178.57 kB 0%
static/js/indexeddb-main-thread-worker-e59fee74.js 13.46 kB 0%
static/js/it.js 165 kB 0%
static/js/narrow.js 364.2 kB 0%
static/js/nb-NO.js 148.05 kB 0%
static/js/nl.js 106.24 kB 0%
static/js/pt-BR.js 188.43 kB 0%
static/js/resize-observer.js 18.06 kB 0%
static/js/th.js 174.48 kB 0%
static/js/theme.js 31.88 kB 0%
static/js/toString.js 705.14 kB 0%
static/js/uk.js 207.46 kB 0%
static/js/useFormatList.js 2.52 kB 0%
static/js/useTransactionBatchActions.js 9.71 kB 0%
static/js/wide.js 297.21 kB 0%
static/js/workbox-window.prod.es5.js 7.33 kB 0%
static/js/zh-Hans.js 116.89 kB 0%

loot-core

Total

Files count Total bundle size % Changed
1 5.34 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._bwMMgjb.js 5.34 MB 0%

api

Total

Files count Total bundle size % Changed
2 3.97 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.97 MB 0%
models.js 0 B 0%

cli

Total

Files count Total bundle size % Changed
1 7.97 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.97 MB 0%

crdt

Total

Files count Total bundle size % Changed
1 11.12 kB 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 11.12 kB 0%

Related work

Related to #7568, which also targets #7303. This PR keeps the fix in the transaction-entry diff application path and currently has a passing release note/check setup. Happy to close or adjust if maintainers prefer reviving the earlier PR.

@kikiminyes
kikiminyes requested a review from joel-jeremy as a code owner May 31, 2026 06:57
@actual-github-bot actual-github-bot Bot changed the title Fix append notes rules on new transactions [WIP] Fix append notes rules on new transactions May 31, 2026
@netlify

netlify Bot commented May 31, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit 6b526a2
🔍 Latest deploy log https://app.netlify.com/projects/actualbudget/deploys/6a1c0df5cf60b40008c3a38f
😎 Deploy Preview https://deploy-preview-8003.demo.actualbudget.org
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

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

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

@kikiminyes kikiminyes changed the title [WIP] Fix append notes rules on new transactions Fix append notes rules on new transactions May 31, 2026
@coderabbitai

coderabbitai Bot commented May 31, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a new applyRuleDiff module to conditionally apply rule diffs to transactions (with notes-merge rules), integrates it into desktop and mobile editors, includes unit tests, and adds a release-note entry documenting the bugfix.

Changes

Rule Diff Application and Integration

Layer / File(s) Summary
Rule diff application logic and module export
packages/desktop-client/src/components/transactions/applyRuleDiff.ts, packages/desktop-client/package.json
New module exports shouldApplyRuleDiff and applyRuleDiffToTransaction with allowlist and notes-merge predicates; adds package.json import alias #components/transactions/applyRuleDiff.
TransactionList rule diff integration
packages/desktop-client/src/components/transactions/TransactionList.tsx
Imports and uses applyRuleDiffToTransaction in onApplyRules, replacing manual per-field overwrite with the helper while keeping parent/subtransaction logic.
Mobile TransactionEdit rule diff integration
packages/desktop-client/src/components/mobile/transactions/TransactionEdit.tsx
Imports and delegates temporary-transaction post-rules diff handling to applyRuleDiffToTransaction instead of inline iteration.
Rule diff test coverage
packages/desktop-client/src/components/transactions/applyRuleDiff.test.ts
Adds tests (transaction factory) covering empty-field population, unchanged absent fields, notes preservation, appended/prepended note composition, substring-regression, and shouldApplyRuleDiff payee case.
Release notes documentation
upcoming-release-notes/8003.md
Adds a Bugfix release-note documenting preservation of existing notes when rules append or prepend text.
sequenceDiagram
  participant UI as TransactionList / TransactionEdit
  participant RulesEngine as rules-run
  participant applyRuleDiff as applyRuleDiffToTransaction
  participant Storage as Transaction state

  UI->>RulesEngine: run rules on transaction
  RulesEngine-->>UI: return diff
  UI->>applyRuleDiff: applyRuleDiffToTransaction(transaction, diff, updatedFieldName)
  applyRuleDiff-->>Storage: return cloned updated transaction
  UI-->>Storage: save/update transaction
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Suggested reviewers

  • joel-jeremy
  • youngcw

Poem

🐰 I hopped across the changed-file sod,
Preserving notes as rules nod.
Append, prepend, the words stay kind,
Old lines kept safe, new ones aligned.
Hooray — tidy transactions, peace of mind!

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: fixing append notes rules on new transactions, which directly addresses issue #7303.
Linked Issues check ✅ Passed The PR successfully addresses issue #7303 by implementing a new applyRuleDiffToTransaction module that allows append/prepend notes rules to update non-empty notes while preserving user-entered text, and applies this logic consistently across desktop and mobile transaction entry components.
Out of Scope Changes check ✅ Passed All changes are in scope: the new applyRuleDiff module, test file, package.json alias, component refactorings, and release notes directly support fixing the notes-append rule behavior described in issue #7303.
Description check ✅ Passed The pull request description is directly related to the changeset, describing centralization of rule diff application and specific fix for append/prepend notes rules.

✏️ 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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/desktop-client/src/components/transactions/applyRuleDiff.ts`:
- Around line 36-43: The isNotesMerge helper currently treats any substring
match as a merge because it uses nextValue.includes(currentValue); change this
to only treat true prepend/append merges by checking that nextValue startsWith
or endsWith currentValue (i.e., replace the includes check with
nextValue.startsWith(currentValue) || nextValue.endsWith(currentValue)) while
keeping the other guards (typeof checks, non-empty, and inequality) in the
isNotesMerge function.

In `@packages/desktop-client/src/components/transactions/TransactionList.tsx`:
- Around line 536-538: The call that creates newTransaction currently invokes
applyRuleDiffToTransaction(transaction, diff) and drops the updatedFieldName,
which prevents the payee special-case in shouldApplyRuleDiff from running;
update that call to pass the field name (updatedFieldName) through to
applyRuleDiffToTransaction so the helper and ultimately shouldApplyRuleDiff
receive the field context and preserve payee-driven rule behavior (ensure any
applyRuleDiffToTransaction signature changes are propagated to where it's
defined and to callers expecting the extra parameter).
🪄 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: 2685c108-41c4-433e-a04a-8603ec6ba0f5

📥 Commits

Reviewing files that changed from the base of the PR and between 000d957 and 03da6ab.

📒 Files selected for processing (6)
  • packages/desktop-client/package.json
  • packages/desktop-client/src/components/mobile/transactions/TransactionEdit.tsx
  • packages/desktop-client/src/components/transactions/TransactionList.tsx
  • packages/desktop-client/src/components/transactions/applyRuleDiff.test.ts
  • packages/desktop-client/src/components/transactions/applyRuleDiff.ts
  • upcoming-release-notes/8003.md

@kikiminyes
kikiminyes force-pushed the fix-append-notes-rule-new-transactions branch from 03da6ab to 564f39e Compare May 31, 2026 07:08
@kikiminyes
kikiminyes force-pushed the fix-append-notes-rule-new-transactions branch from 564f39e to 6b526a2 Compare May 31, 2026 10:31
@kikiminyes kikiminyes changed the title Fix append notes rules on new transactions [AI] Fix append notes rules on new transactions May 31, 2026
@MatissJanis

Copy link
Copy Markdown
Member

Closing in favour of #8300

This branch was previously deployed

1 inactive deployment
pr-automation — 6b526a2d Deployed May 31, 2026 by kikiminyes via check-release-notes #24155
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Append to notes rule not working if a note already exists

2 participants