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

Add Upcoming length adjustment feature flag #3651

Merged
merged 13 commits into from
Oct 18, 2024

Conversation

SamBobBarnes
Copy link
Contributor

Add feature flag for upcoming length adjustment feature.

@actual-github-bot actual-github-bot bot changed the title Add Upcoming length adjustment feature flag [WIP] Add Upcoming length adjustment feature flag Oct 12, 2024
Copy link

netlify bot commented Oct 12, 2024

Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit f9a0572
🔍 Latest deploy log https://app.netlify.com/sites/actualbudget/deploys/670f241276a70d00081096bd
😎 Deploy Preview https://deploy-preview-3651.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.

Copy link
Contributor

github-actions bot commented Oct 12, 2024

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
9 5.34 MB → 5.34 MB (+476 B) +0.01%
Changeset
File Δ Size
src/hooks/useFeatureFlag.ts 📈 +35 B (+10.09%) 347 B → 382 B
src/components/settings/Experimental.tsx 📈 +350 B (+7.55%) 4.52 kB → 4.87 kB
src/components/settings/Upcoming.tsx 📈 +91 B (+3.75%) 2.37 kB → 2.46 kB
View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

Asset File Size % Changed
static/js/index.js 3.34 MB → 3.34 MB (+385 B) +0.01%
static/js/wide.js 243.06 kB → 243.15 kB (+91 B) +0.04%

Smaller

No assets were smaller

Unchanged

Asset File Size % Changed
static/js/resize-observer.js 18.37 kB 0%
static/js/BackgroundImage.js 122.29 kB 0%
static/js/indexeddb-main-thread-worker-e59fee74.js 13.5 kB 0%
static/js/usePreviewTransactions.js 1.64 kB 0%
static/js/AppliedFilters.js 21.31 kB 0%
static/js/narrow.js 82.58 kB 0%
static/js/ReportRouter.js 1.51 MB 0%

Copy link
Contributor

github-actions bot commented Oct 12, 2024

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

@SamBobBarnes SamBobBarnes changed the title [WIP] Add Upcoming length adjustment feature flag Add Upcoming length adjustment feature flag Oct 12, 2024
Copy link
Contributor

coderabbitai bot commented Oct 12, 2024

Walkthrough

The pull request introduces a new feature flag, upcomingLengthAdjustment, across multiple components in the desktop client. In Experimental.tsx, a FeatureToggle component is added to enable or disable the upcoming length adjustment feature, including a label for internationalization and a feedback link directing users to a GitHub issue. In Upcoming.tsx, the component utilizes the useFeatureFlag hook to check if the feature is enabled, conditionally rendering the UI based on this state. The useFeatureFlag.ts file is updated to include the new feature flag in the DEFAULT_FEATURE_FLAG_STATE, initializing it to false. The prefs.d.ts file is modified to reflect this change in the FeatureFlag type by removing the old flag 'actionTemplating' and adding the new flag 'upcomingLengthAdjustment'. The test file schedules.test.js is updated to accommodate testing for the new feature flag, while the SettingsPage class in settings-page.js has its method enableExperimentalFeature renamed to toggleExperimentalFeature, maintaining existing functionality.

Possibly related PRs

Suggested labels

sparkles: Merged

Suggested reviewers

  • youngcw
  • MatissJanis

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

🧹 Outside diff range and nitpick comments (3)
packages/desktop-client/src/hooks/useFeatureFlag.ts (1)

11-11: LGTM! Consider sorting feature flags alphabetically.

The addition of the upcomingLengthAdjustment feature flag is correct and follows the established pattern. The default value of false is appropriate for a new feature flag.

For improved readability and easier maintenance, consider sorting the feature flags alphabetically within the DEFAULT_FEATURE_FLAG_STATE object. This would make it easier to locate specific flags as the list grows.

packages/desktop-client/src/components/settings/Upcoming.tsx (2)

46-47: LGTM: Conditional rendering based on feature flag.

The conditional rendering is correctly implemented, preventing the component from rendering when the feature flag is off. This aligns with the PR objective and allows for easy toggling of the feature.

Consider adding a brief comment explaining the purpose of this check for future maintainers:

+ // Only render the component if the upcomingLengthAdjustment feature is enabled
  if (!enabled) return null;

Line range hint 9-47: Summary: Feature flag implementation for upcoming length adjustment.

The changes in this file successfully implement the feature flag for the upcoming length adjustment feature. The key points are:

  1. The useFeatureFlag hook is imported and used correctly.
  2. The feature flag state is checked before rendering the component.
  3. The implementation allows for easy toggling of the feature without code changes.

These changes align well with the PR objective and follow best practices for feature flag implementation.

Consider documenting the purpose and usage of this feature flag in a central location (e.g., a README or feature flag documentation file) to help other developers understand its impact across the application.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 5cb97d6 and afd62e7.

⛔ Files ignored due to path filters (1)
  • upcoming-release-notes/3651.md is excluded by !**/*.md
📒 Files selected for processing (4)
  • packages/desktop-client/src/components/settings/Experimental.tsx (1 hunks)
  • packages/desktop-client/src/components/settings/Upcoming.tsx (2 hunks)
  • packages/desktop-client/src/hooks/useFeatureFlag.ts (1 hunks)
  • packages/loot-core/src/types/prefs.d.ts (1 hunks)
🧰 Additional context used
🔇 Additional comments (3)
packages/desktop-client/src/components/settings/Upcoming.tsx (2)

9-9: LGTM: New import for feature flag hook.

The import statement for useFeatureFlag is correctly placed and necessary for the new feature flag functionality.


41-42: LGTM: Feature flag initialization.

The enabled constant is correctly initialized using the useFeatureFlag hook with the appropriate flag name 'upcomingLengthAdjustment'. This aligns with the PR objective of adding a feature flag for the upcoming length adjustment feature.

packages/desktop-client/src/components/settings/Experimental.tsx (1)

119-124: LGTM! New feature toggle added correctly.

The new FeatureToggle for "upcomingLengthAdjustment" is implemented correctly and follows the existing pattern in the file. The use of the Trans component for internationalization is appropriate.

There's a TODO comment about creating a feedback issue. It would be beneficial to create this issue and update the feedbackLink prop before merging this PR.

Let's verify if the new feature flag is properly defined in the relevant files:

packages/loot-core/src/types/prefs.d.ts Show resolved Hide resolved
Copy link
Member

@MatissJanis MatissJanis left a comment

Choose a reason for hiding this comment

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

Code LGTM! Would you mind updating the VRT screenshots so the vrt CI job would pass?

@MatissJanis MatissJanis self-assigned this Oct 13, 2024
@SamBobBarnes
Copy link
Contributor Author

Would you mind updating the VRT screenshots so the vrt CI job would pass?

@MatissJanis is there a way to generate these?

@youngcw
Copy link
Member

youngcw commented Oct 13, 2024

Would you mind updating the VRT screenshots so the vrt CI job would pass?

@MatissJanis is there a way to generate these?

The readme for the desktop client package says how to generate new ones

@youngcw youngcw added this to the v24.11.0 milestone Oct 15, 2024
@SamBobBarnes
Copy link
Contributor Author

The readme for the desktop client package says how to generate new ones

@MatissJanis I'm sure I'm doing something wrong, but I've been pulling my hair out for 2 days trying to get these VRT screenshots generated and getting nowhere.

Most common error I get when I try to run them is net::ERR_CONNECTION_REFUSED at https://localhost:3100/

I have tried to run them locally, in docker, and against localhost and my lan ip.
I am running the app via yarn start with HTTPS=true env variable set.
I can hit the site with my browser, but playwright is acting like it doesn't exist.
I have also tried to run the server via the docker compose up --build command, but that runs into an expired cert somewhere and doesnt build.

Could this be CORS acting up?

I wish there was better documentation on how to get this working. Seems like the current docs in the readme dont have any good troubleshooting tips. Any helpful tips you could give would be greatly appreciated. I have not used playwright before, so could by my env as well. I have tried this on windows and mac with the same result.

@youngcw
Copy link
Member

youngcw commented Oct 15, 2024

My process is to:

  • run yarn just to make sure all deps are met
  • open a new terminal run HTTPS=true yarn start
  • in original terminal run yarn vrt:docker --e2e-start-url https://192.168.1.3:3001 --update-snapshots

I've never been able to use localhost and have it work so maybe just don't even try using localhost in place of the IP. I just filled in an example IP for now. Then git status should show the updated snapshots if any needed changed

@SamBobBarnes
Copy link
Contributor Author

My process is to:

  • run yarn just to make sure all deps are met
  • open a new terminal run HTTPS=true yarn start
  • in original terminal run yarn vrt:docker --e2e-start-url https://192.168.1.3:3001 --update-snapshots

I've never been able to use localhost and have it work so maybe just don't even try using localhost in place of the IP. I just filled in an example IP for now. Then git status should show the updated snapshots if any needed changed

Tried it as described on my mac, and it worked first time. Dont know what I was doing wrong other than localhost. Thanks @youngcw!

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

🧹 Outside diff range and nitpick comments (3)
packages/desktop-client/e2e/schedules.test.js (3)

1-1: LGTM, but consider maintaining import order consistency.

The reordering of imports is fine, but it's a good practice to maintain a consistent import order across all files in the project. Consider using a linter or formatter to automatically manage import orders.


29-31: Remove commented-out test code.

Instead of leaving the old test commented out, it's better to remove it entirely. If you need to reference this code later, you can always find it in the git history. Keeping commented-out code can lead to confusion and clutter in the codebase.


Line range hint 58-128: Consider running existing test with different feature flag states.

The existing test for creating a new schedule and posting the transaction is comprehensive and remains unchanged. However, to ensure complete coverage, consider running this test with different states of the 'upcomingLengthAdjustment' feature flag as well.

You could move this test inside the feature flag loop or create a separate loop for it. This would help ensure that the new feature doesn't unexpectedly affect existing functionality. Here's a suggestion:

[true, false].forEach(upcomingLengthAdjustment => {
  test.describe(`with upcoming length adjustment flag ${upcomingLengthAdjustment ? 'on' : 'off'}`, () => {
    // ... (existing setup and teardown)

    test('creates a new schedule, posts the transaction and later completes it', async () => {
      // ... (existing test code)
    });
  });
});

This change would run the test twice, once with the feature flag on and once with it off, providing more comprehensive coverage.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ca6ef40 and 7169521.

⛔ Files ignored due to path filters (21)
  • packages/desktop-client/e2e/schedules.test.js-snapshots/Schedules-checks-the-page-visuals-1-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/schedules.test.js-snapshots/Schedules-checks-the-page-visuals-2-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/schedules.test.js-snapshots/Schedules-checks-the-page-visuals-3-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/schedules.test.js-snapshots/Schedules-creates-a-new-schedule-posts-the-transaction-and-later-completes-it-1-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/schedules.test.js-snapshots/Schedules-creates-a-new-schedule-posts-the-transaction-and-later-completes-it-10-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/schedules.test.js-snapshots/Schedules-creates-a-new-schedule-posts-the-transaction-and-later-completes-it-11-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/schedules.test.js-snapshots/Schedules-creates-a-new-schedule-posts-the-transaction-and-later-completes-it-12-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/schedules.test.js-snapshots/Schedules-creates-a-new-schedule-posts-the-transaction-and-later-completes-it-2-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/schedules.test.js-snapshots/Schedules-creates-a-new-schedule-posts-the-transaction-and-later-completes-it-3-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/schedules.test.js-snapshots/Schedules-creates-a-new-schedule-posts-the-transaction-and-later-completes-it-4-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/schedules.test.js-snapshots/Schedules-creates-a-new-schedule-posts-the-transaction-and-later-completes-it-5-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/schedules.test.js-snapshots/Schedules-creates-a-new-schedule-posts-the-transaction-and-later-completes-it-6-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/schedules.test.js-snapshots/Schedules-creates-a-new-schedule-posts-the-transaction-and-later-completes-it-7-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/schedules.test.js-snapshots/Schedules-creates-a-new-schedule-posts-the-transaction-and-later-completes-it-8-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/schedules.test.js-snapshots/Schedules-creates-a-new-schedule-posts-the-transaction-and-later-completes-it-9-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/schedules.test.js-snapshots/Schedules-with-upcoming-length-adjustment-flag-off-checks-the-page-visuals-1-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/schedules.test.js-snapshots/Schedules-with-upcoming-length-adjustment-flag-off-checks-the-page-visuals-2-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/schedules.test.js-snapshots/Schedules-with-upcoming-length-adjustment-flag-off-checks-the-page-visuals-3-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/schedules.test.js-snapshots/Schedules-with-upcoming-length-adjustment-flag-on-checks-the-page-visuals-1-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/schedules.test.js-snapshots/Schedules-with-upcoming-length-adjustment-flag-on-checks-the-page-visuals-2-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/schedules.test.js-snapshots/Schedules-with-upcoming-length-adjustment-flag-on-checks-the-page-visuals-3-chromium-linux.png is excluded by !**/*.png
📒 Files selected for processing (1)
  • packages/desktop-client/e2e/schedules.test.js (2 hunks)
🧰 Additional context used

packages/desktop-client/e2e/schedules.test.js Outdated Show resolved Hide resolved
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

🧹 Outside diff range and nitpick comments (1)
packages/desktop-client/e2e/page-models/settings-page.js (1)

Line range hint 20-33: Approve method renaming and suggest error handling improvement

The renaming of the method to toggleExperimentalFeature is consistent with its usage and improves clarity. The implementation correctly handles the process of toggling an experimental feature.

Consider adding error handling to improve robustness:

 async toggleExperimentalFeature(featureName) {
-  const advancedSettingsButton = this.page.getByTestId('advanced-settings');
-  await advancedSettingsButton.click();
+  try {
+    const advancedSettingsButton = this.page.getByTestId('advanced-settings');
+    await advancedSettingsButton.click();
 
-  const experimentalSettingsButton = this.page.getByTestId(
-    'experimental-settings',
-  );
-  await experimentalSettingsButton.click();
+    const experimentalSettingsButton = this.page.getByTestId(
+      'experimental-settings',
+    );
+    await experimentalSettingsButton.click();
 
-  const featureCheckbox = this.page.getByRole('checkbox', {
-    name: featureName,
-  });
-  await featureCheckbox.click();
+    const featureCheckbox = this.page.getByRole('checkbox', {
+      name: featureName,
+    });
+    await featureCheckbox.click();
+  } catch (error) {
+    console.error(`Failed to toggle feature '${featureName}':`, error);
+    throw error;
+  }
 }

This change would provide better error reporting if any of the UI interactions fail, which can be helpful in debugging test failures.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 7169521 and 5d2b1e8.

📒 Files selected for processing (2)
  • packages/desktop-client/e2e/page-models/settings-page.js (2 hunks)
  • packages/desktop-client/e2e/schedules.test.js (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/desktop-client/e2e/schedules.test.js
🧰 Additional context used
🔇 Additional comments (1)
packages/desktop-client/e2e/page-models/settings-page.js (1)

11-11: Approve method renaming: Improved clarity and flexibility

The renaming of enableExperimentalFeature to toggleExperimentalFeature is a positive change. It more accurately reflects the method's functionality, suggesting that it can both enable and disable the feature. This improves code readability and maintainability.

@SamBobBarnes SamBobBarnes force-pushed the Upcoming-length-feature-flag branch from 5d2b1e8 to f9a0572 Compare October 16, 2024 02:25
@youngcw youngcw merged commit 3f31d19 into actualbudget:master Oct 18, 2024
36 checks passed
This was referenced Oct 21, 2024
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.

4 participants