A local-first personal finance app
automation UI: various tweaks and fixes (#7832)
Matt Fiddaman9b19cd2616c2
diff --git a/packages/desktop-client/src/components/budget/BalanceWithCarryover.tsx b/packages/desktop-client/src/components/budget/BalanceWithCarryover.tsxindex 9f5ff7e370..205480ba57 100644--- a/packages/desktop-client/src/components/budget/BalanceWithCarryover.tsx+++ b/packages/desktop-client/src/components/budget/BalanceWithCarryover.tsx@@ -193,7 +193,7 @@ export function BalanceWithCarryover({<div>{{- type: longGoalValue === 1 ? t('Long') : t('Template'),+ type: longGoalValue === 1 ? t('Goal') : t('Automation'),} as TransObjectLiteral}</div>diff --git a/packages/desktop-client/src/components/budget/goals/automationMessages.tsx b/packages/desktop-client/src/components/budget/goals/automationMessages.tsxindex 384e653ca8..aac32eab0c 100644--- a/packages/desktop-client/src/components/budget/goals/automationMessages.tsx+++ b/packages/desktop-client/src/components/budget/goals/automationMessages.tsx@@ -19,6 +19,8 @@ export function AutomationErrorTitle({return <Trans>Schedule not found</Trans>;case 'refill-no-cap':return <Trans>Refill needs a balance cap</Trans>;+ case 'limit-no-contributor':+ return <Trans>Balance cap needs a contributing automation</Trans>;case 'percentage-out-of-range':return <Trans>Percentage out of range</Trans>;case 'percentage-no-source':@@ -53,7 +55,9 @@ export function AutomationErrorShort({<Trans>Pick a schedule</Trans>);case 'refill-no-cap':- return <Trans>Add a balance cap above</Trans>;+ return <Trans>Add a balance cap</Trans>;+ case 'limit-no-contributor':+ return <Trans>Add an automation that contributes funds</Trans>;case 'percentage-out-of-range':return (<Trans>{{ percent: error.percent }}% must be between 0 and 100</Trans>@@ -100,6 +104,14 @@ export function AutomationErrorDetail({added to use as the target.</Trans>);+ case 'limit-no-contributor':+ return (+ <Trans>+ A balance cap on its own does nothing. Add a contributing automation+ (such as a fixed amount, save by date, or whatever is left) so the cap+ has something to clamp.+ </Trans>+ );case 'percentage-out-of-range':return <Trans>Set a value greater than 0% and at most 100%.</Trans>;case 'percentage-no-source':diff --git a/packages/desktop-client/src/components/budget/goals/displayTemplateMeta.ts b/packages/desktop-client/src/components/budget/goals/displayTemplateMeta.tsindex 6950ea6fb2..071c4eab33 100644--- a/packages/desktop-client/src/components/budget/goals/displayTemplateMeta.ts+++ b/packages/desktop-client/src/components/budget/goals/displayTemplateMeta.ts@@ -38,7 +38,7 @@ export function getDisplayTemplateMeta(case 'schedule':return {label: t('Cover schedule'),- description: t('Save up for a recurring scheduled transaction.'),+ description: t('Save up for a scheduled transaction.'),icon: SvgCalendar3,};case 'by':diff --git a/packages/desktop-client/src/components/budget/goals/validateAutomation.ts b/packages/desktop-client/src/components/budget/goals/validateAutomation.tsindex 842c2e3e19..01005b39d5 100644--- a/packages/desktop-client/src/components/budget/goals/validateAutomation.ts+++ b/packages/desktop-client/src/components/budget/goals/validateAutomation.ts@@ -7,6 +7,7 @@ import type { DisplayTemplateType } from './constants';export type AutomationErrorKind =| { kind: 'schedule-not-found'; name: string }| { kind: 'refill-no-cap' }+ | { kind: 'limit-no-contributor' }| { kind: 'percentage-out-of-range'; percent: number }| { kind: 'percentage-no-source' }| { kind: 'percentage-source-not-found'; source: string }@@ -48,6 +49,15 @@ export function validateAutomation(return { kind: 'refill-no-cap' };}return null;+ case 'limit':+ if (+ !allTemplates.some(+ t => t.type !== 'limit' && t.type !== 'goal' && t.type !== 'error',+ )+ ) {+ return { kind: 'limit-no-contributor' };+ }+ return null;case 'percentage':if (template.type !== 'percentage') return null;if (!template.category) return { kind: 'percentage-no-source' };diff --git a/packages/desktop-client/src/components/modals/BudgetAutomationsModal/AutomationListRow.tsx b/packages/desktop-client/src/components/modals/BudgetAutomationsModal/AutomationListRow.tsxindex fb75297552..91952972ef 100644--- a/packages/desktop-client/src/components/modals/BudgetAutomationsModal/AutomationListRow.tsx+++ b/packages/desktop-client/src/components/modals/BudgetAutomationsModal/AutomationListRow.tsx@@ -3,6 +3,7 @@ import { useTranslation } from 'react-i18next';import { SvgAlertTriangle } from '@actual-app/components/icons/v2';import { Text } from '@actual-app/components/text';import { theme } from '@actual-app/components/theme';+import { Tooltip } from '@actual-app/components/tooltip';import { View } from '@actual-app/components/view';import type { AutomationEntry } from '#components/budget/goals/automationExamples';@@ -126,18 +127,24 @@ export function AutomationListRow({/>)}</View>- <Text- style={{- fontSize: 11,- color: subtitleColor,- overflow: 'hidden',- textOverflow: 'ellipsis',- whiteSpace: 'nowrap',- display: 'block',- }}+ <Tooltip+ content={+ <Text style={{ display: 'block', maxWidth: 320 }}>{subtitle}</Text>+ }>- {subtitle}- </Text>+ <Text+ style={{+ fontSize: 11,+ color: subtitleColor,+ overflow: 'hidden',+ textOverflow: 'ellipsis',+ whiteSpace: 'nowrap',+ display: 'block',+ }}+ >+ {subtitle}+ </Text>+ </Tooltip></View>{!NON_CONTRIBUTION_TYPES.has(entry.displayType) && (<Viewdiff --git a/packages/desktop-client/src/components/modals/BudgetAutomationsModal/BudgetAutomationsModal.test.ts b/packages/desktop-client/src/components/modals/BudgetAutomationsModal/BudgetAutomationsModal.test.tsindex 4292ae2854..26ed93f8bf 100644--- a/packages/desktop-client/src/components/modals/BudgetAutomationsModal/BudgetAutomationsModal.test.ts+++ b/packages/desktop-client/src/components/modals/BudgetAutomationsModal/BudgetAutomationsModal.test.ts@@ -100,6 +100,31 @@ describe('migrateTemplatesToAutomations', () => {});});+ it('expands `#template 0 up to N` into limit + fixed-zero (not refill)', () => {+ const simpleTemplate = {+ type: 'simple',+ directive: 'template',+ priority: 4,+ monthly: 0,+ limit: {+ amount: 1000,+ hold: false,+ period: 'monthly',+ },+ } satisfies Template;++ const result = migrateTemplatesToAutomations([simpleTemplate]);++ expect(result).toHaveLength(2);+ expect(result.map(entry => entry.displayType)).toEqual(['limit', 'fixed']);+ expect(result[1].template).toMatchObject({+ type: 'periodic',+ amount: 0,+ directive: 'template',+ priority: 4,+ });+ });+it('expands a simple template with both limit and monthly into limit + periodic (no implicit refill)', () => {// `#template 20 up to 200 per week` budgets 20/month and caps at the// limit — the engine's runSimple returns just the monthly value, sodiff --git a/packages/desktop-client/src/components/modals/BudgetAutomationsModal/migrateTemplatesToAutomations.ts b/packages/desktop-client/src/components/modals/BudgetAutomationsModal/migrateTemplatesToAutomations.tsindex b14355ef27..e792940124 100644--- a/packages/desktop-client/src/components/modals/BudgetAutomationsModal/migrateTemplatesToAutomations.ts+++ b/packages/desktop-client/src/components/modals/BudgetAutomationsModal/migrateTemplatesToAutomations.ts@@ -47,7 +47,8 @@ export function migrateTemplatesToAutomations(templates.forEach(template => {if (template.type === 'simple') {const monthly = template.monthly;- const hasMonthly = monthly != null && monthly !== 0;+ const hasMonthly =+ monthly != null && (monthly !== 0 || template.limit != null);if (template.limit) {entries.push(@@ -64,10 +65,7 @@ export function migrateTemplatesToAutomations('limit',),);- // The implicit refill only applies to a limit-only simple template- // (e.g. `#template up to 200`). When a monthly amount is also set- // (`#template 50 up to 200`), the engine just budgets the monthly- // amount and clamps to the cap — no top-up to the limit.+if (!hasMonthly) {entries.push(createAutomationEntry(@@ -81,6 +79,7 @@ export function migrateTemplatesToAutomations();}}+if (hasMonthly) {entries.push(createAutomationEntry(diff --git a/packages/desktop-client/src/components/util/AmountInput.tsx b/packages/desktop-client/src/components/util/AmountInput.tsxindex 2d88f1897f..2837450aff 100644--- a/packages/desktop-client/src/components/util/AmountInput.tsx+++ b/packages/desktop-client/src/components/util/AmountInput.tsx@@ -220,6 +220,7 @@ export function AmountInput({onFocus={e => {setIsFocused(true);setValue(format.forEdit(Math.abs(initialValue ?? 0)));+ setTimeout(() => innerRef.current?.select(), 0);onFocus?.(e);}}onBlur={e => {diff --git a/upcoming-release-notes/7832.md b/upcoming-release-notes/7832.mdnew file mode 100644index 0000000000..9fc27a84ac--- /dev/null+++ b/upcoming-release-notes/7832.md@@ -0,0 +1,6 @@+---+category: Maintenance+authors: [matt-fidd]+---++Automation UI: various tweaks and fixes