Skip to content

Conversation

@zackspear
Copy link
Contributor

@zackspear zackspear commented Jul 11, 2025

Requested in feature PR #1490 (comment)

Summary by CodeRabbit

  • New Features

    • Enhanced trial expiration messaging to clearly communicate when the trial is expiring, options for extension, and the consequences of expiration.
    • Added dynamic display of trial extension options and actions based on eligibility and time remaining before expiration.
  • Bug Fixes

    • Improved accuracy of messages and actions related to trial extension eligibility and renewal windows.
  • Tests

    • Added comprehensive tests for trial extension eligibility, renewal windows, and related user messages and actions.
  • Documentation

    • Updated English locale strings to reflect new trial expiration and extension messages.

zackspear added 5 commits July 8, 2025 16:33
Consolidated trial message handling to reduce redundancy and improve readability. The logic now checks conditions for trial expiration and extension eligibility more efficiently, ensuring users receive accurate information based on their trial status.
…ging

Implemented new tests in `server.test.ts` to validate trial extension eligibility, expiration conditions, and corresponding user messages. This includes checks for eligibility based on `regGen` values and expiration timing, ensuring accurate feedback for users regarding their trial status.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 11, 2025

Walkthrough

This update introduces new computed properties and logic in the server store to manage Unraid OS trial extension eligibility and renewal messaging. It updates localized strings for trial expiration scenarios and adds comprehensive tests to verify the new trial extension conditions, dynamic messages, and available actions in the user interface.

Changes

File(s) Change Summary
web/store/server.ts Added computed properties for trial extension eligibility and renewal window; updated stateData logic and actions.
web/locales/en_US.json Added new localized strings for trial expiration and extension messaging.
web/test/store/server.test.ts Added tests for trial extension eligibility, renewal window, dynamic trial messages, and action availability.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI
    participant ServerStore

    User->>UI: Views trial status
    UI->>ServerStore: Reads computed properties
    ServerStore-->>UI: Returns eligibility and renewal window status
    alt Eligible and within renewal window
        UI-->>User: Show extend option and expiring soon message
    else Ineligible or outside window
        UI-->>User: Show appropriate message (no extension or wait)
    end
Loading

Possibly related PRs

Poem

When trials near their end,
New messages now extend,
With actions clear and bright,
Extend your trial, or buy outright!
Five days to ponder,
Eligibility to wonder—
Unraid guides you right!

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

Base automatically changed from feat/trial-extensions-before-expiration to main July 11, 2025 00:21
@github-actions
Copy link
Contributor

This plugin has been deployed to Cloudflare R2 and is available for testing.
Download it at this URL:

https://preview.dl.unraid.net/unraid-api/tag/PR1504/dynamix.unraid.net.plg

@elibosley
Copy link
Member

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 11, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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 (1)
web/store/server.ts (1)

514-523: Consider extracting hardcoded HTML messages to localization files.

The conditional logic correctly handles all trial extension scenarios. However, the HTML content is hardcoded which could impact maintainability and localization.

Consider moving these messages to the localization files and referencing them here:

-          trialMessage = '<p>Your <em>Trial</em> key includes all the functionality and device support of an <em>Unleashed</em> key.</p><p>Your trial is expiring soon. When it expires, <strong>the array will stop</strong>. You may extend your trial now, purchase a license key, or wait until expiration to take action.</p>';
+          trialMessage = this.$t('server.trial.eligibleInsideRenewalWindow');
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f34a33b and dbf2887.

📒 Files selected for processing (3)
  • web/__test__/store/server.test.ts (1 hunks)
  • web/locales/en_US.json (1 hunks)
  • web/store/server.ts (3 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: elibosley
PR: unraid/api#1101
File: api/src/unraid-api/unraid-file-modifier/modifications/patches/default-page-layout.patch:24-27
Timestamp: 2025-01-31T22:01:22.708Z
Learning: The Unraid UI uses a modern notification system with a custom `unraid-toaster` component replacing the legacy jGrowl notifications. The system is backed by a comprehensive GraphQL API with real-time subscription support for notification updates.
Learnt from: mdatelle
PR: unraid/api#1106
File: unraid-ui/src/components/index.ts:2-2
Timestamp: 2025-02-04T17:21:39.710Z
Learning: The unraid-ui package is undergoing a major refactoring process, and breaking changes are expected during this transition period.
Learnt from: elibosley
PR: unraid/api#1101
File: api/src/unraid-api/unraid-file-modifier/modifications/patches/default-page-layout.patch:6-20
Timestamp: 2025-01-31T22:01:41.842Z
Learning: The default-page-layout.patch removes the old jGrowl notification system and is complemented by the unraid-toaster component implementation. The new system is added through the DefaultPageLayout modification which inserts the toaster component with proper position configuration based on user preferences.
Learnt from: elibosley
PR: unraid/api#1211
File: unraid-ui/src/components/form/number/NumberFieldInput.vue:1-21
Timestamp: 2025-03-13T16:17:21.897Z
Learning: The unraid-ui is a UI library being published externally, where wrapping third-party components (like those from reka-ui) is an intentional design choice to maintain a consistent interface, standardize styling, and control the exposed API.
Learnt from: elibosley
PR: unraid/api#1082
File: api/src/unraid-api/unraid-file-modifier/modifications/log-rotate.modification.ts:33-37
Timestamp: 2025-01-29T16:36:04.777Z
Learning: The UnraidFileModifierService in the Unraid API provides comprehensive error handling for all FileModification implementations. It includes try/catch blocks, detailed error logging, and safe rollback mechanisms. Individual FileModification implementations (like LogRotateModification) should allow errors to propagate to this service layer rather than handling them internally.
Learnt from: elibosley
PR: unraid/api#1101
File: api/src/unraid-api/unraid-file-modifier/modifications/patches/default-page-layout.patch:6-20
Timestamp: 2025-01-31T22:01:41.842Z
Learning: The default-page-layout.patch is used to remove the old jGrowl notification system from Unraid pages, as notifications are handled by a new system implemented on a different page.
web/locales/en_US.json (1)
Learnt from: zackspear
PR: unraid/api#1257
File: plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix/include/ReplaceKey.php:184-184
Timestamp: 2025-03-20T01:58:31.676Z
Learning: Error messages from the key server or KeyInstaller do not contain PII or server details, so they can be safely used in notifications.
web/__test__/store/server.test.ts (11)
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-testing-rules.mdc:0-0
Timestamp: 2025-06-30T14:52:37.535Z
Learning: Applies to **/__test__/store/**/*.ts : Verify state changes by updating the store in store tests
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-testing-rules.mdc:0-0
Timestamp: 2025-06-30T14:52:37.535Z
Learning: Applies to **/__test__/store/**/*.ts : Mock external dependencies appropriately in store tests
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-testing-rules.mdc:0-0
Timestamp: 2025-06-30T14:52:37.535Z
Learning: Applies to **/__test__/store/**/*.ts : Verify state changes after actions in store tests
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-testing-rules.mdc:0-0
Timestamp: 2025-06-30T14:52:37.535Z
Learning: Applies to **/__test__/store/**/*.ts : Test action side effects and state changes in store tests
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-testing-rules.mdc:0-0
Timestamp: 2025-06-30T14:52:37.535Z
Learning: Applies to **/__test__/store/**/*.ts : Test getter dependencies are properly mocked in store tests
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-testing-rules.mdc:0-0
Timestamp: 2025-06-30T14:52:37.535Z
Learning: Applies to **/__test__/store/**/*.ts : Test async operations completely in store tests
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-testing-rules.mdc:0-0
Timestamp: 2025-06-30T14:52:37.535Z
Learning: Applies to **/__test__/store/**/*.ts : Test store interactions with other stores in store tests
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-testing-rules.mdc:0-0
Timestamp: 2025-06-30T14:52:37.535Z
Learning: Applies to **/__test__/store/**/*.ts : Test action side effects if not stubbed in store tests
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-testing-rules.mdc:0-0
Timestamp: 2025-06-30T14:52:37.535Z
Learning: Applies to **/__test__/store/**/*.ts : Override specific action implementations when needed in store tests
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-testing-rules.mdc:0-0
Timestamp: 2025-06-30T14:52:37.535Z
Learning: Applies to **/__test__/store/**/*.ts : Verify proper error handling in store tests
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-testing-rules.mdc:0-0
Timestamp: 2025-06-30T14:52:37.535Z
Learning: Applies to **/__test__/store/**/*.ts : Verify actions are called with correct parameters in store tests
web/store/server.ts (10)
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-testing-rules.mdc:0-0
Timestamp: 2025-06-30T14:52:37.535Z
Learning: Applies to **/__test__/store/**/*.ts : Verify state changes by updating the store in store tests
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-testing-rules.mdc:0-0
Timestamp: 2025-06-30T14:52:37.535Z
Learning: Applies to **/__test__/store/**/*.ts : Verify state changes after actions in store tests
Learnt from: elibosley
PR: unraid/api#1063
File: web/_data/serverState.ts:137-147
Timestamp: 2025-01-27T14:57:46.617Z
Learning: The values in `web/_data/serverState.ts` are used for testing purposes and should remain as hardcoded mock data to facilitate testing different scenarios.
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-testing-rules.mdc:0-0
Timestamp: 2025-06-30T14:52:37.535Z
Learning: Applies to **/__test__/store/**/*.ts : Test action side effects and state changes in store tests
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-testing-rules.mdc:0-0
Timestamp: 2025-06-30T14:52:37.535Z
Learning: Applies to **/__test__/store/**/*.ts : Verify proper error handling in store tests
Learnt from: CR
PR: unraid/api#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T14:50:43.946Z
Learning: Applies to web/store/**/*.{ts,js} : Ensure Vue reactivity imports are added to store files (computed, ref, watchEffect)
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-testing-rules.mdc:0-0
Timestamp: 2025-06-30T14:52:37.535Z
Learning: Applies to **/__test__/store/**/*.ts : Set initial state for focused testing in store tests
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-testing-rules.mdc:0-0
Timestamp: 2025-06-30T14:52:37.535Z
Learning: Applies to **/__test__/store/**/*.ts : Test store interactions with other stores in store tests
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-testing-rules.mdc:0-0
Timestamp: 2025-06-30T14:52:37.535Z
Learning: Applies to **/__test__/store/**/*.ts : Mock external dependencies appropriately in store tests
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-testing-rules.mdc:0-0
Timestamp: 2025-06-30T14:52:37.535Z
Learning: Applies to **/__test__/store/**/*.ts : Test action side effects if not stubbed in store tests
🔇 Additional comments (10)
web/locales/en_US.json (1)

26-29: LGTM! Well-structured trial extension messaging.

The new locale strings are clear, consistent, and properly formatted. They effectively communicate the different trial extension scenarios and the updated behavior where the array stops upon expiration. The messaging provides users with appropriate guidance on available actions.

web/__test__/store/server.test.ts (5)

768-792: Comprehensive trial extension eligibility testing.

The test correctly validates the eligibility logic based on regGen values. The implementation properly covers all scenarios: undefined, 0, 1 (eligible) and 2+ (ineligible).


794-834: Thorough expiration window calculation testing.

The test comprehensively validates the 5-day expiration window logic with proper edge cases including non-trial states, missing expiration times, and various day ranges. The use of dayjs for date calculations is appropriate.


836-904: Well-structured renewal window condition testing.

The test effectively validates the combination of eligibility and expiration window conditions. The four scenarios (eligible inside/outside, ineligible inside/outside) are all properly tested with correct state expectations.


906-1001: Excellent dynamic message testing.

The test validates that the correct trial messages are displayed based on extension eligibility and renewal window status. The message content verification ensures the UI will display appropriate guidance to users in each scenario.


1003-1084: Solid action availability testing.

The test properly validates that the trial extend action is only available when eligible and within the renewal window. This ensures the UI only presents valid actions to users.

web/store/server.ts (4)

498-498: LGTM! Clean variable declaration.

The trialMessage variable is properly declared to hold dynamic trial content.


528-528: Perfect conditional action inclusion.

The trial extend action is correctly included only when the user is eligible and within the renewal window.


533-533: LGTM! Dynamic message implementation.

The message field now correctly uses the dynamic trialMessage variable instead of static content.


787-798: Well-structured computed properties for trial logic.

The computed properties are clearly named and implement the trial extension logic correctly. The trialWithin5DaysOfExpiration properly handles edge cases and the dependent computed properties create a clean separation of concerns.

One minor note: The date calculation logic correctly handles the 0-5 day range using daysUntilExpiration <= 5 && daysUntilExpiration >= 0.

@elibosley elibosley merged commit 6c03df2 into main Jul 11, 2025
8 checks passed
@elibosley elibosley deleted the tests/trial-extensions branch July 11, 2025 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants