Repository navigation
Conversation
✅ Deploy Preview for actualbudget ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
🤖 AI-assisted implementation. I could not apply the \AI generated\ label from the fork due permissions. |
|
👋 Hello contributor! We would love to review your PR! Before we can do that, please make sure:
A quick note on volume: please get one PR reviewed and merged before opening several more. A stack of simultaneous, similar PRs from one author is reviewed slowly, and low-effort, untested, or undisclosed-AI PRs may be closed without a detailed review. 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. |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughBudget template and cleanup operations now return shared notification identifiers and metadata. The desktop client translates these identifiers, formats count-based messages, and dispatches localized notifications. Tests and release notes reflect the updated notification contract. ChangesBudget template notification translation
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant TemplateAction
participant useBudgetActions
participant translateBudgetTemplateNotification
participant NotificationsStore
TemplateAction->>useBudgetActions: return typed template notification
useBudgetActions->>translateBudgetTemplateNotification: translate message and counts
translateBudgetTemplateNotification-->>useBudgetActions: localized notification
useBudgetActions->>NotificationsStore: dispatch localized notification
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
packages/desktop-client/src/budget/mutations.ts (1)
63-67: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueExport the
BudgetTemplateNotificationtype.Exporting this type is a good practice since it is used as a parameter in the exported
translateBudgetTemplateNotificationfunction. This prevents potential TypeScript declaration errors (TS4058) and allows consumers of the function to explicitly type their arguments if needed.♻️ Proposed refactor
-type BudgetTemplateNotification = Notification & { +export type BudgetTemplateNotification = Notification & { count?: number | undefined; sourceCount?: number | undefined; sinkCount?: number | undefined; };🤖 Prompt for 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. In `@packages/desktop-client/src/budget/mutations.ts` around lines 63 - 67, Export the BudgetTemplateNotification type so it is publicly available alongside the exported translateBudgetTemplateNotification function. Keep its existing fields and type definition unchanged.packages/desktop-client/src/budget/mutations.test.ts (1)
38-44: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd test coverage for
cleanup-appliedpluralization logic.The
formatCleanupAppliedfunction has several branches for handling singular/plural combinations ofsourceCountandsinkCount. Adding a test case for these combinations would ensure the pluralization logic remains fully covered and regressions are prevented.🧪 Proposed test cases
it('leaves non-template notifications unchanged', () => { expect( translateBudgetTemplateNotification({ message: 'Already translated' }, t) .message, ).toBe('Already translated'); }); + + it('translates cleanup notification counts with appropriate pluralization', () => { + expect( + translateBudgetTemplateNotification( + { message: 'cleanup-applied', sourceCount: 1, sinkCount: 2 }, + t, + ).message, + ).toBe( + 'Successfully returned funds from {{sourceCount}} source and funded {{sinkCount}} sinking funds.:{"sourceCount":1,"sinkCount":2}', + ); + + expect( + translateBudgetTemplateNotification( + { message: 'cleanup-applied', sourceCount: 2, sinkCount: 1 }, + t, + ).message, + ).toBe( + 'Successfully returned funds from {{sourceCount}} sources and funded {{sinkCount}} sinking fund.:{"sourceCount":2,"sinkCount":1}', + ); + }); });🤖 Prompt for 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. In `@packages/desktop-client/src/budget/mutations.test.ts` around lines 38 - 44, Add test coverage in the budget notification tests for the cleanup-applied path handled by formatCleanupApplied, exercising its singular/plural combinations for sourceCount and sinkCount. Assert the resulting translated message for each combination while preserving the existing non-template notification test.
🤖 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.
Nitpick comments:
In `@packages/desktop-client/src/budget/mutations.test.ts`:
- Around line 38-44: Add test coverage in the budget notification tests for the
cleanup-applied path handled by formatCleanupApplied, exercising its
singular/plural combinations for sourceCount and sinkCount. Assert the resulting
translated message for each combination while preserving the existing
non-template notification test.
In `@packages/desktop-client/src/budget/mutations.ts`:
- Around line 63-67: Export the BudgetTemplateNotification type so it is
publicly available alongside the exported translateBudgetTemplateNotification
function. Keep its existing fields and type definition unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 75a3a690-1b43-4345-a65b-e2a1d5425c0d
📒 Files selected for processing (9)
packages/desktop-client/src/budget/mutations.test.tspackages/desktop-client/src/budget/mutations.tspackages/loot-core/src/server/budget/cleanup-template.tspackages/loot-core/src/server/budget/goal-template.test.tspackages/loot-core/src/server/budget/goal-template.tspackages/loot-core/src/server/budget/template-notes.test.tspackages/loot-core/src/server/budget/template-notes.tspackages/loot-core/src/server/budget/template-notification.tsupcoming-release-notes/translate-budget-template-notifications.md
jfdoming
left a comment
There was a problem hiding this comment.
Looks pretty good, thanks for working on this! One small issue with pluralization, otherwise looks good
| if (sourceCount === 1 && sinkCount === 1) { | ||
| return t( | ||
| 'Successfully returned funds from {{sourceCount}} source and funded {{sinkCount}} sinking fund.', | ||
| { sourceCount, sinkCount }, | ||
| ); | ||
| } | ||
| if (sourceCount === 1) { | ||
| return t( | ||
| 'Successfully returned funds from {{sourceCount}} source and funded {{sinkCount}} sinking funds.', | ||
| { sourceCount, sinkCount }, | ||
| ); | ||
| } | ||
| if (sinkCount === 1) { | ||
| return t( | ||
| 'Successfully returned funds from {{sourceCount}} sources and funded {{sinkCount}} sinking fund.', | ||
| { sourceCount, sinkCount }, | ||
| ); |
There was a problem hiding this comment.
You shouldn't need all these cases, the translation software will allow i18next to choose the right pluralization for at least one of these if you use a variable called count and only one conditional. However that still doesn't handle all cases since some languages can have several plural forms—the best way would probably be to use https://www.i18next.com/translation-function/nesting#passing-options-to-nestings.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
packages/loot-core/src/server/budget/cleanup-template.ts (1)
336-340: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winConsider returning
cleanup-appliedwhen sources were processed.Because this block is in the
elsebranch ofif (num_sources === 0), we know that funds were successfully returned from one or more sources. Returningcleanup-up-to-datehere hides that information. If you remove thiselse ifbranch, the logic will fall through tocleanup-appliedand correctly reportSuccessfully returned funds from {{sourceCount}} sources...even if no sinks were funded becausebudgetAvailablewas 0.♻️ Proposed refactor
- } else if (budgetAvailable === 0) { - return { - type: 'message', - message: 'cleanup-up-to-date', - }; } else { return {🤖 Prompt for 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. In `@packages/loot-core/src/server/budget/cleanup-template.ts` around lines 336 - 340, Remove the `else if (budgetAvailable === 0)` branch in the cleanup result logic so execution falls through to the existing `cleanup-applied` response whenever sources were processed, including when no sinks could be funded. Preserve the `num_sources === 0` handling and reuse the existing source-count success message.packages/desktop-client/src/budget/mutations.test.ts (1)
67-104: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueUse
it.eachfor parametrized tests.Consider using Vitest's
it.eachinstead of a loop inside a singleitblock. This approach provides better test reporting because each iteration runs as a separate, independent test. If one case fails, it will output the specific parameters that caused the failure without preventing the remaining cases from executing.💡 Proposed refactor to use `it.each`
- it('translates cleanup notification counts with i18next pluralization', () => { - const cases = [ - [ - 0, - 0, - 'Successfully returned funds from 0 sources and funded 0 sinking funds.', - ], - [ - 1, - 1, - 'Successfully returned funds from 1 source and funded 1 sinking fund.', - ], - [ - 1, - 2, - 'Successfully returned funds from 1 source and funded 2 sinking funds.', - ], - [ - 2, - 1, - 'Successfully returned funds from 2 sources and funded 1 sinking fund.', - ], - [ - 2, - 2, - 'Successfully returned funds from 2 sources and funded 2 sinking funds.', - ], - ] as const; - - for (const [sourceCount, sinkCount, expected] of cases) { - expect( - translateBudgetTemplateNotification( - { message: 'cleanup-applied', sourceCount, sinkCount }, - pluralT, - ).message, - ).toBe(expected); - } - }); + it.each([ + [ + 0, + 0, + 'Successfully returned funds from 0 sources and funded 0 sinking funds.', + ], + [ + 1, + 1, + 'Successfully returned funds from 1 source and funded 1 sinking fund.', + ], + [ + 1, + 2, + 'Successfully returned funds from 1 source and funded 2 sinking funds.', + ], + [ + 2, + 1, + 'Successfully returned funds from 2 sources and funded 1 sinking fund.', + ], + [ + 2, + 2, + 'Successfully returned funds from 2 sources and funded 2 sinking funds.', + ], + ])( + 'translates cleanup notification counts with i18next pluralization (source: %i, sink: %i)', + (sourceCount, sinkCount, expected) => { + expect( + translateBudgetTemplateNotification( + { message: 'cleanup-applied', sourceCount, sinkCount }, + pluralT, + ).message, + ).toBe(expected); + }, + );🤖 Prompt for 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. In `@packages/desktop-client/src/budget/mutations.test.ts` around lines 67 - 104, Refactor the cleanup notification test around translateBudgetTemplateNotification to use Vitest’s it.each with the existing cases as parameterized inputs. Remove the manual for loop and keep each sourceCount, sinkCount, and expected message assertion unchanged.
🤖 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/loot-core/src/server/budget/cleanup-template.ts`:
- Around line 323-329: Update the cleanup-applied-with-errors notification
return object in the cleanup flow to include type: 'error', matching the
equivalent num_sources === 0 error branch while preserving the existing fields.
---
Nitpick comments:
In `@packages/desktop-client/src/budget/mutations.test.ts`:
- Around line 67-104: Refactor the cleanup notification test around
translateBudgetTemplateNotification to use Vitest’s it.each with the existing
cases as parameterized inputs. Remove the manual for loop and keep each
sourceCount, sinkCount, and expected message assertion unchanged.
In `@packages/loot-core/src/server/budget/cleanup-template.ts`:
- Around line 336-340: Remove the `else if (budgetAvailable === 0)` branch in
the cleanup result logic so execution falls through to the existing
`cleanup-applied` response whenever sources were processed, including when no
sinks could be funded. Preserve the `num_sources === 0` handling and reuse the
existing source-count success message.
🪄 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: 85a30cb7-7ba8-4911-92e1-3d88307ccf68
📒 Files selected for processing (6)
packages/desktop-client/src/budget/mutations.test.tspackages/desktop-client/src/budget/mutations.tspackages/loot-core/src/server/budget/cleanup-template.tspackages/loot-core/src/server/budget/goal-template.tspackages/loot-core/src/server/budget/template-notes.tspackages/loot-core/src/server/budget/template-notification.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- packages/loot-core/src/server/budget/template-notes.ts
- packages/loot-core/src/server/budget/goal-template.ts
- packages/desktop-client/src/budget/mutations.ts
a2500f8 to
a2a0b8e
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/budget/mutations.ts`:
- Around line 69-91: Update formatCleanupApplied and the
cleanup-applied-with-errors formatting path to use full-sentence translation
keys with i18next nesting and count values, rather than translating
source/sinking fund fragments and interpolating a prebuilt sentence. Remove
reliance on the generic standalone keys, while preserving the existing
zero-default counts and error-case content.
🪄 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: 88e7db71-4c50-4bb7-b555-5991924d7d33
📒 Files selected for processing (9)
packages/desktop-client/src/budget/mutations.test.tspackages/desktop-client/src/budget/mutations.tspackages/loot-core/src/server/budget/cleanup-template.tspackages/loot-core/src/server/budget/goal-template.test.tspackages/loot-core/src/server/budget/goal-template.tspackages/loot-core/src/server/budget/template-notes.test.tspackages/loot-core/src/server/budget/template-notes.tspackages/loot-core/src/server/budget/template-notification.tsupcoming-release-notes/translate-budget-template-notifications.md
🚧 Files skipped from review as they are similar to previous changes (8)
- upcoming-release-notes/translate-budget-template-notifications.md
- packages/loot-core/src/server/budget/template-notification.ts
- packages/loot-core/src/server/budget/cleanup-template.ts
- packages/desktop-client/src/budget/mutations.test.ts
- packages/loot-core/src/server/budget/template-notes.test.ts
- packages/loot-core/src/server/budget/template-notes.ts
- packages/loot-core/src/server/budget/goal-template.ts
- packages/loot-core/src/server/budget/goal-template.test.ts
|
@coderabbitai review |
✅ Action performedReview finished.
|
| // i18next-parser does not extract keys nested inside translation strings. | ||
| // t('budget-template-source', { count: 1, defaultValue_one: '{{count}} source', defaultValue_other: '{{count}} sources' }) | ||
| // t('budget-template-sinking-fund', { count: 1, defaultValue_one: '{{count}} sinking fund', defaultValue_other: '{{count}} sinking funds' }) |
There was a problem hiding this comment.
Darn, this is kind of unfortunate. Perhaps we should open an upstream issue...
There was a problem hiding this comment.
are we then giving up on this trajectory? I seem to notice this issue has been closed?
There was a problem hiding this comment.
Why do you say the issue has been closed? It looks open to me
There was a problem hiding this comment.
haha darn it, I saw the last thing by coderabbitai mentioning 8487 and thought it was about this 8478 my badd
There was a problem hiding this comment.
@youngcw I was leaving this PR open to give others a chance to comment, if you're fine with this approach then I'll just merge it
There was a problem hiding this comment.
The only reason I can think of to pause is if we wanted to update how the messages were handled with the new GUI system, but that can still be done later if we decide to
There was a problem hiding this comment.
I'm happy with this for now, I think it'll be a while until I get around to the way that things are applied at the moment, unless someone else wants to tackle it
* [AI] Fix budget template notification translations * [AI] Address PR review feedback * [AI] Preserve cleanup error notifications * [AI] Use nested cleanup translation keys
Description
Budget template actions were returning English notification strings from
loot-core, so the desktop client could only display them as-is.This changes the server side to return stable notification keys plus the small bits of data the UI needs, like counts. The desktop client then maps those keys to normal translatable strings before showing the notification.
This follows the direction discussed on the existing PRs for #8413: keep i18n string extraction in the client instead of trying to make dynamic server strings translatable.
AI-assisted implementation drafted with Codex, then reviewed and edited before submission.
Related issue(s)
Fixes #8413
Testing
Tested locally:
corepack yarn generate:i18ncorepack yarn workspace @actual-app/core test:node src/server/budget/goal-template.test.ts src/server/budget/template-notes.test.tscorepack yarn workspace @actual-app/web test src/budget/mutations.test.tscorepack yarn exec oxfmt --check ...corepack yarn exec oxlint --type-aware --quiet ...corepack yarn workspace @actual-app/core typecheckcorepack yarn workspace @actual-app/web typecheckAlso verified the PR diff only includes the intended budget-template notification files and release note.
Checklist
Bundle Stats
View detailed bundle stats
desktop-client
Total
Changeset
src/budget/mutations.tsView detailed bundle breakdown
Added
No assets were added
Removed
No assets were removed
Bigger
Smaller
No assets were smaller
Unchanged
loot-core
Total
Changeset
home/runner/work/actual/actual/packages/loot-core/src/server/budget/template-notes.tshome/runner/work/actual/actual/packages/loot-core/src/server/budget/goal-template.tshome/runner/work/actual/actual/packages/loot-core/src/server/budget/cleanup-template.tsView detailed bundle breakdown
Added
Removed
Bigger
No assets were bigger
Smaller
No assets were smaller
Unchanged
No assets were unchanged
api
Total
Changeset
home/runner/work/actual/actual/packages/loot-core/src/server/budget/template-notes.tshome/runner/work/actual/actual/packages/loot-core/src/server/budget/goal-template.tshome/runner/work/actual/actual/packages/loot-core/src/server/budget/cleanup-template.tsView detailed bundle breakdown
Added
No assets were added
Removed
No assets were removed
Bigger
No assets were bigger
Smaller
Unchanged
cli
Total
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
crdt
Total
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