Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: reconcile on context menu #4252

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

UnderKoen
Copy link
Member

@UnderKoen UnderKoen commented Jan 28, 2025

image

@actual-github-bot actual-github-bot bot changed the title feat: reconcile on context menu [WIP] feat: reconcile on context menu Jan 28, 2025
Copy link
Contributor

github-actions bot commented Jan 28, 2025

Bundle Stats — desktop-client

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files count Total bundle size % Changed
17 6.94 MB → 6.94 MB (+2.38 kB) +0.03%
Changeset
File Δ Size
src/components/sidebar/Account.tsx 📈 +1.93 kB (+24.97%) 7.72 kB → 9.64 kB
src/components/accounts/Account.tsx 📈 +461 B (+0.97%) 46.45 kB → 46.9 kB
View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

Asset File Size % Changed
static/js/index.js 4.31 MB → 4.31 MB (+1.93 kB) +0.04%
static/js/wide.js 102.8 kB → 103.25 kB (+461 B) +0.44%

Smaller

No assets were smaller

Unchanged

Asset File Size % Changed
static/js/en-GB.js 99.42 kB 0%
static/js/fr.js 72.19 kB 0%
static/js/nl.js 98.54 kB 0%
static/js/de.js 111.72 kB 0%
static/js/en.js 100.65 kB 0%
static/js/workbox-window.prod.es5.js 5.69 kB 0%
static/js/indexeddb-main-thread-worker-e59fee74.js 13.5 kB 0%
static/js/resize-observer.js 18.37 kB 0%
static/js/BackgroundImage.js 122.29 kB 0%
static/js/pt-BR.js 106.43 kB 0%
static/js/uk.js 111.11 kB 0%
static/js/useAccountPreviewTransactions.js 1.69 kB 0%
static/js/AppliedFilters.js 10.52 kB 0%
static/js/narrow.js 85.57 kB 0%
static/js/ReportRouter.js 1.59 MB 0%

Copy link
Contributor

github-actions bot commented Jan 28, 2025

Bundle Stats — loot-core

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files count Total bundle size % Changed
1 1.33 MB 0%

Changeset

No files were changed

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.js 1.33 MB 0%

Copy link

netlify bot commented Jan 28, 2025

Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit 326e632
🔍 Latest deploy log https://app.netlify.com/sites/actualbudget/deploys/67b63ef5cf4c5500084bf4be
😎 Deploy Preview https://deploy-preview-4252.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 site configuration.

@UnderKoen UnderKoen changed the title [WIP] feat: reconcile on context menu feat: reconcile on context menu Jan 28, 2025
Copy link
Contributor

coderabbitai bot commented Jan 28, 2025

Walkthrough

The pull request introduces changes to two files in the desktop-client package: Account.tsx in both the accounts and sidebar components. In the accounts/Account.tsx, modifications focus on adding a reconcileAmount property to the AccountInternalProps type, allowing the AccountInternal component to manage reconciliation amounts dynamically through props and state management. The sidebar/Account.tsx file undergoes extensive changes, including the addition of internationalization support via the useTranslation hook, enhanced state management by separating editing states for account name and balance, and improved user interaction capabilities. These changes collectively enhance the functionality and usability of the account management components.

Possibly related PRs

Suggested labels

sparkles: Merged

Suggested reviewers

  • youngcw
  • matt-fidd

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (3)
packages/desktop-client/src/components/sidebar/Account.tsx (1)

Line range hint 198-224: Consider enhancing error feedback for name editing.

While the implementation handles validation correctly, it would be beneficial to provide visual feedback to users when validation fails.

Consider adding error state handling:

 <InitialFocus>
   <Input
     style={{
       padding: 0,
       width: '100%',
+      borderColor: nameError ? theme.errorText : undefined,
     }}
     onBlur={() => setIsEditingName(false)}
     onEnter={e => {
       const inputEl = e.target as HTMLInputElement;
       const newAccountName = inputEl.value;
       if (newAccountName.trim() !== '') {
         dispatch(
           updateAccount({
             account: {
               ...account,
               name: newAccountName,
             },
           }),
         );
       }
       setIsEditingName(false);
     }}
     onEscape={() => setIsEditingName(false)}
     defaultValue={name}
   />
+  {nameError && (
+    <Text style={{ color: theme.errorText, fontSize: 12 }}>
+      {nameError}
+    </Text>
+  )}
 </InitialFocus>
packages/desktop-client/src/components/accounts/Account.tsx (2)

372-372: Consider adding type annotation for reconcileAmount initialization.

While the initialization is correct, adding a type annotation would improve type safety.

-      reconcileAmount: props.reconcileAmount,
+      reconcileAmount: props.reconcileAmount as number | null,

477-480: Consider simplifying the reconcileAmount update.

The update logic could be more concise by directly updating the state.

-    if (this.props.reconcileAmount !== prevProps.reconcileAmount) {
-      this.setState({ reconcileAmount: this.props.reconcileAmount });
-    }
+    this.props.reconcileAmount !== prevProps.reconcileAmount &&
+      this.setState({ reconcileAmount: this.props.reconcileAmount });
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d1c3b9b and 478840b.

⛔ Files ignored due to path filters (1)
  • upcoming-release-notes/4252.md is excluded by !**/*.md
📒 Files selected for processing (2)
  • packages/desktop-client/src/components/accounts/Account.tsx (4 hunks)
  • packages/desktop-client/src/components/sidebar/Account.tsx (9 hunks)
🧰 Additional context used
📓 Learnings (3)
📓 Common learnings
Learnt from: joel-jeremy
PR: actualbudget/actual#3685
File: packages/desktop-client/src/components/accounts/Account.tsx:655-665
Timestamp: 2024-11-10T16:45:31.225Z
Learning: The Account component in 'packages/desktop-client/src/components/accounts/Account.tsx' is being rewritten in a separate PR.
packages/desktop-client/src/components/accounts/Account.tsx (1)
Learnt from: joel-jeremy
PR: actualbudget/actual#3685
File: packages/desktop-client/src/components/accounts/Account.tsx:655-665
Timestamp: 2024-11-10T16:45:31.225Z
Learning: The Account component in 'packages/desktop-client/src/components/accounts/Account.tsx' is being rewritten in a separate PR.
packages/desktop-client/src/components/sidebar/Account.tsx (1)
Learnt from: joel-jeremy
PR: actualbudget/actual#3685
File: packages/desktop-client/src/components/accounts/Account.tsx:655-665
Timestamp: 2024-11-10T16:45:31.225Z
Learning: The Account component in 'packages/desktop-client/src/components/accounts/Account.tsx' is being rewritten in a separate PR.
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: build (macos-latest)
  • GitHub Check: build (windows-latest)
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: Wait for Netlify build to finish
  • GitHub Check: Analyze
🔇 Additional comments (5)
packages/desktop-client/src/components/sidebar/Account.tsx (3)

3-3: LGTM! Well-organized imports and hooks.

The new imports and hooks provide necessary functionality for internationalization, currency handling, and value formatting.

Also applies to: 13-13, 40-41


114-115: LGTM! Clear separation of editing states.

The split between isEditingName and isEditingBalance improves code clarity and maintainability by separating concerns.


292-293: LGTM! Well-implemented menu internationalization.

The menu items are properly internationalized using the translation hook, and the reconcile functionality is well-integrated.

packages/desktop-client/src/components/accounts/Account.tsx (2)

310-310: LGTM! Well-typed reconcileAmount property.

The reconcileAmount property is properly typed with null union type for optional values.


2029-2029: LGTM! Proper props passing with null fallback.

The reconcileAmount prop is correctly passed with a null fallback using the nullish coalescing operator.

@youngcw
Copy link
Member

youngcw commented Jan 28, 2025

The cleared/locked column disappears after reconciling via the context menu.

…-context-menu

# Conflicts:
#	packages/desktop-client/src/components/sidebar/Account.tsx
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (1)
packages/desktop-client/src/components/sidebar/Account.tsx (1)

230-257: 🛠️ Refactor suggestion

Validate balance input before reconciliation.

The balance editing implementation should validate the input to ensure it's a valid currency value before conversion.

Add validation to prevent invalid currency inputs:

 onEnter={e => {
   const inputEl = e.target as HTMLInputElement;
   const newValue = inputEl.value;
-  if (newValue.trim() !== '') {
+  const currencyRegex = /^-?\d*\.?\d{0,2}$/;
+  if (newValue.trim() !== '' && currencyRegex.test(newValue)) {
     const v = currencyToInteger(newValue);
     navigate(to, { state: { reconcileAmount: v } });
+  } else {
+    // Show error message to user
+    console.error('Invalid currency format');
   }
   setIsEditingBalance(false);
 }}
🧹 Nitpick comments (2)
packages/desktop-client/src/components/sidebar/Account.tsx (1)

293-294: Add keyboard accessibility for reconciliation.

The reconciliation menu item should be accessible via keyboard shortcuts for better usability.

Add keyboard shortcut:

 { name: 'rename', text: t('Rename') },
-{ name: 'reconcile', text: t('Reconcile') },
+{ name: 'reconcile', text: t('Reconcile'), shortcut: 'Ctrl+R' },

Also applies to: 285-287

packages/desktop-client/src/components/accounts/Account.tsx (1)

310-310: Consider making reconcileAmount required.

Since reconciliation is a core feature, consider making reconcileAmount a required prop by removing the | null type to ensure it's always provided with a valid value.

-  reconcileAmount: number | null;
+  reconcileAmount: number;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 478840b and 4a4b512.

📒 Files selected for processing (2)
  • packages/desktop-client/src/components/accounts/Account.tsx (4 hunks)
  • packages/desktop-client/src/components/sidebar/Account.tsx (9 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: joel-jeremy
PR: actualbudget/actual#3685
File: packages/desktop-client/src/components/accounts/Account.tsx:655-665
Timestamp: 2024-11-10T16:45:31.225Z
Learning: The Account component in 'packages/desktop-client/src/components/accounts/Account.tsx' is being rewritten in a separate PR.
packages/desktop-client/src/components/sidebar/Account.tsx (1)
Learnt from: joel-jeremy
PR: actualbudget/actual#3685
File: packages/desktop-client/src/components/accounts/Account.tsx:655-665
Timestamp: 2024-11-10T16:45:31.225Z
Learning: The Account component in 'packages/desktop-client/src/components/accounts/Account.tsx' is being rewritten in a separate PR.
packages/desktop-client/src/components/accounts/Account.tsx (1)
Learnt from: joel-jeremy
PR: actualbudget/actual#3685
File: packages/desktop-client/src/components/accounts/Account.tsx:655-665
Timestamp: 2024-11-10T16:45:31.225Z
Learning: The Account component in 'packages/desktop-client/src/components/accounts/Account.tsx' is being rewritten in a separate PR.
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: build (macos-latest)
  • GitHub Check: build (windows-latest)
  • GitHub Check: Wait for Netlify build to finish
  • GitHub Check: Analyze
  • GitHub Check: build (ubuntu-latest)
🔇 Additional comments (2)
packages/desktop-client/src/components/sidebar/Account.tsx (1)

115-116: Split editing state for better control.

Good separation of concerns by splitting the editing state into isEditingName and isEditingBalance. This improves state management by allowing independent control over name and balance editing.

packages/desktop-client/src/components/accounts/Account.tsx (1)

1-2041:

❓ Verification inconclusive

Potential merge conflicts ahead.

This component is being rewritten in another PR (#3685). Coordinate with that PR to ensure changes are properly merged and reconciliation functionality is preserved in the rewrite.


🏁 Script executed:

#!/bin/bash
# Check for potential conflicts with PR #3685
gh pr diff 3685 | grep -A 5 "packages/desktop-client/src/components/accounts/Account.tsx"

Length of output: 611


Potential merge conflicts ahead.

It appears that this component is undergoing a rewrite in PR [#3685]. The recent diff output indicates changes in key areas (e.g. around the schedules query imports) that might not be fully compatible with the current branch. Please coordinate with the team handling the rewrite to ensure that any modifications—especially those related to reconciliation functionality and query handling—are merged correctly without breaking the intended behavior.

@youngcw
Copy link
Member

youngcw commented Feb 17, 2025

I think the number input box for setting the amount is a little tight. Could that be just a bit taller?

Would it be possible to not navigate to the account page if the account is already matching the entered balance? Maybe pop up a notification instead of navigating to the account?

The default amount for the reconcile should be the cleared total.

@UnderKoen
Copy link
Member Author

The default amount for the reconcile should be the cleared total.

When you click on the account the non cleared amount is showed, would you not expect this to be the number there when entering?

also adds padding to the name input field to make the consistent
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
packages/desktop-client/src/components/sidebar/Account.tsx (3)

118-119: Add type safety to state variables.

Consider adding explicit types to the state variables to improve type safety and documentation.

-  const [isEditingName, setIsEditingName] = useState(false);
-  const [isEditingBalance, setIsEditingBalance] = useState(false);
+  const [isEditingName, setIsEditingName] = useState<boolean>(false);
+  const [isEditingBalance, setIsEditingBalance] = useState<boolean>(false);

209-223: Add input validation for account name.

The current implementation only checks if the name is not empty. Consider adding more robust validation.

 onEnter={e => {
   const inputEl = e.target as HTMLInputElement;
   const newAccountName = inputEl.value;
-  if (newAccountName.trim() !== '') {
+  const trimmedName = newAccountName.trim();
+  if (trimmedName !== '' && trimmedName.length <= 50) {
     dispatch(
       updateAccount({
         account: {
           ...account,
-          name: newAccountName,
+          name: trimmedName,
         },
       }),
     );
+  } else {
+    dispatch(
+      addNotification({
+        type: 'error',
+        message: 'Account name must be between 1 and 50 characters.',
+      }),
+    );
   }
   setIsEditingName(false);
 }}

236-240: Improve input field styling for better usability.

As per PR feedback, the input field appears tight. Consider adjusting the height for better usability.

 style={{
   width: '100%',
   textAlign: 'right',
   ...styles.tnum,
+  height: '24px',
+  padding: '4px 8px',
 }}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a55c21d and 326e632.

📒 Files selected for processing (1)
  • packages/desktop-client/src/components/sidebar/Account.tsx (9 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: joel-jeremy
PR: actualbudget/actual#3685
File: packages/desktop-client/src/components/accounts/Account.tsx:655-665
Timestamp: 2024-11-10T16:45:31.225Z
Learning: The Account component in 'packages/desktop-client/src/components/accounts/Account.tsx' is being rewritten in a separate PR.
packages/desktop-client/src/components/sidebar/Account.tsx (1)
Learnt from: joel-jeremy
PR: actualbudget/actual#3685
File: packages/desktop-client/src/components/accounts/Account.tsx:655-665
Timestamp: 2024-11-10T16:45:31.225Z
Learning: The Account component in 'packages/desktop-client/src/components/accounts/Account.tsx' is being rewritten in a separate PR.
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: Visual regression
  • GitHub Check: Functional
  • GitHub Check: build (windows-latest)
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: Analyze
🔇 Additional comments (2)
packages/desktop-client/src/components/sidebar/Account.tsx (2)

263-263: Consider using cleared total as default value.

As suggested in PR feedback, using the cleared total as the default value might improve the reconciliation workflow.

Could you clarify whether users would expect the cleared total or the current balance as the default value? This would help determine the best approach.


297-300:

❓ Verification inconclusive

Verify cleared/locked column behavior.

Per PR feedback, the cleared/locked column disappears after reconciling via the context menu.


🏁 Script executed:

#!/bin/bash
# Search for code handling the cleared/locked column visibility
rg -A 5 "cleared.*column|locked.*column"

Length of output: 42


Action Required: Verify cleared/locked column behavior

The context provided in the PR feedback indicates that the cleared/locked column disappears after reconciling via the context menu, yet our investigation via the grep search for "cleared.*column" or "locked.*column" in the codebase returned no results. This lack of evidence suggests that the logic regarding the cleared/locked column may not be explicitly handled in the current implementation.

Next steps:

  • Manually verify if the cleared/locked column behavior is implemented elsewhere or if it is indeed missing.
  • Review any related changes in the code that might indirectly affect this behavior.

@youngcw
Copy link
Member

youngcw commented Feb 20, 2025

The default amount for the reconcile should be the cleared total.

When you click on the account the non cleared amount is showed, would you not expect this to be the number there when entering?

I feel like it should match the standard reconcile process. The existing processes uses the cleared amount even if thats not what is showed as the account balance at the top.

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.

3 participants