Skip to content

Add cached settings for listViewOrderbookFilters #1700

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

Merged
merged 18 commits into from
May 9, 2025
Merged

Conversation

hardingjam
Copy link
Contributor

@hardingjam hardingjam commented Apr 25, 2025

❗ First, merge #1698

  • Save the user choice for orderHash to filter order results.
  • Save user choice for active networks
  • Save user choice for showing only connected wallet data

Checks

By submitting this for review, I'm confirming I've done the following:

  • made this PR as small as possible
  • unit-tested any new functionality
  • linked any relevant issues or PRs
  • included screenshots (if this involves a front-end change)

Summary by CodeRabbit

  • New Features
    • Added persistent user settings for application configuration, item visibility, order status, subgraph selection, and selected order hash, all saved locally.
  • Bug Fixes
    • Improved handling of order status filtering to ensure accurate display of active and inactive orders.
  • Refactor
    • Streamlined state management by sourcing settings directly from persistent stores rather than page data or local stores.
    • Updated checkbox component logic for managing active order status.
    • Enforced boolean type for active order status across components and stores.
    • Synchronized cached settings store with page data on layout initialization.
  • Style
    • No visual changes introduced.

Copy link
Contributor

coderabbitai bot commented Apr 25, 2025

"""

Walkthrough

This change introduces several new persistent writable stores in the settings module, each backed by local storage with JSON serialization and error handling. The stores are now imported and used directly in Svelte components, replacing previous reliance on page data or local writable stores. UI components and their props are updated to use the new store types and logic. The activeOrderStatus store's type was narrowed to strictly boolean with a default of true, and related components and tests were updated accordingly.

Changes

File(s) Change Summary
packages/webapp/src/lib/stores/settings.ts Added new persistent writable stores (settings, showMyItemsOnly, activeOrderStatus, activeSubgraphs, orderHash) using cachedWritableStore, with local storage, JSON serialization, and error handling. Documented each store's purpose and default value. Changed activeOrderStatus type from `boolean
packages/webapp/src/routes/+layout.svelte Imported the settings store and synchronized it with the value from $page.data.stores.settings during component initialization.
packages/webapp/src/routes/orders/+page.svelte Replaced imports of connected and writable with direct imports of new settings stores. Removed destructuring of related stores from page data. Updated logic to use imported stores directly and passed them as props to components. Removed reactive statement setting showMyItemsOnly from connected.
packages/webapp/src/routes/vaults/+page.svelte Replaced imports of connected and writable with direct imports of new settings stores. Removed destructuring of related stores from page data. Updated logic to use imported stores directly and passed them as props to components. Removed reactive statement setting showMyItemsOnly from connected.
packages/ui-components/src/lib/components/checkbox/CheckboxActiveOrders.svelte Changed the prop type of activeOrderStatus from `Writable<boolean
packages/ui-components/src/lib/components/tables/OrdersListTable.svelte Updated the logic for the active property in the getOrders query: it now sets active to true if $activeOrderStatus is truthy, otherwise to undefined, altering the filtering logic for active orders.
packages/ui-components/src/__tests__/ListViewOrderbookFilters.test.ts Changed default initial value of activeOrderStatus store in test props from undefined to true.
packages/ui-components/src/lib/__mocks__/stores.ts Changed initial value and type of mockActiveOrderStatusWritable from `boolean
packages/ui-components/src/lib/components/ListViewOrderbookFilters.svelte Changed exported prop type of activeOrderStatus from `Writable<boolean
packages/ui-components/src/lib/components/tables/VaultsListTable.svelte Changed exported prop type of activeOrderStatus from `Writable<boolean
packages/ui-components/src/lib/types/appStores.ts Updated activeOrderStatus property type in AppStoresInterface from `Writable<boolean
tauri-app/src/lib/stores/settings.ts Changed activeOrderStatus cached writable store type from `boolean

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SvelteComponent
    participant SettingsStore (localStorage)
    participant UIComponent

    User->>SvelteComponent: Interacts (e.g. toggles checkbox)
    SvelteComponent->>SettingsStore: Update store value (e.g. showMyItemsOnly, activeOrderStatus)
    SettingsStore->>localStorage: Persist value (JSON serialize)
    SvelteComponent->>UIComponent: Pass updated store as prop
    UIComponent->>SettingsStore: Read current value (subscribe)
    SettingsStore->>UIComponent: Emit current value
Loading

Possibly related PRs

Suggested labels

webapp, test

Suggested reviewers

  • hardyjosh
    """

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 644d276 and 875b262.

📒 Files selected for processing (1)
  • tauri-app/src/lib/stores/settings.ts (1 hunks)
🔇 Additional comments (1)
tauri-app/src/lib/stores/settings.ts (1)

241-253: Type narrowing improvement for activeOrderStatus store

The change from potentially undefined to a strictly boolean type with a default value of true improves type safety and consistency. The updated deserialization logic now properly handles cases where the stored value isn't a boolean, defaulting to true in those situations.

This change aligns well with the PR objective of caching list view orderbook filters and follows the same pattern used in other settings like hideZeroBalanceVaults.

✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ 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.

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.

@hardingjam hardingjam changed the base branch from main to Cache-stores-in-webapp April 25, 2025 15:38
@hardingjam hardingjam changed the title Save more filters Add cached setting for orderHash filter Apr 25, 2025
@hardingjam hardingjam marked this pull request as ready for review April 25, 2025 15:59
@hardingjam hardingjam changed the title Add cached setting for orderHash filter Add cached settings for listViewOrderbookFilters Apr 25, 2025
@hardingjam hardingjam requested a review from hardyjosh April 25, 2025 16:53
@hardingjam hardingjam self-assigned this Apr 25, 2025
@hardingjam hardingjam linked an issue Apr 25, 2025 that may be closed by this pull request
@hardingjam hardingjam changed the base branch from Cache-stores-in-webapp to main April 25, 2025 17:34
@hardingjam hardingjam added the enhancement New feature or request label Apr 25, 2025
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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 572d038 and 33cbf62.

📒 Files selected for processing (8)
  • packages/ui-components/src/lib/index.ts (1 hunks)
  • packages/ui-components/src/lib/storesGeneric/cachedWritableStore.ts (1 hunks)
  • packages/webapp/src/lib/index.ts (0 hunks)
  • packages/webapp/src/lib/stores/settings.ts (1 hunks)
  • packages/webapp/src/routes/+layout.svelte (1 hunks)
  • packages/webapp/src/routes/orders/+page.svelte (1 hunks)
  • packages/webapp/src/routes/vaults/+page.svelte (1 hunks)
  • tauri-app/src/lib/storesGeneric/fetchableStore.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • packages/webapp/src/lib/index.ts
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/webapp/src/lib/stores/settings.ts (2)
packages/ui-components/src/lib/storesGeneric/cachedWritableStore.ts (1)
  • cachedWritableStore (30-64)
packages/ui-components/src/lib/index.ts (2)
  • cachedWritableStore (120-120)
  • ConfigSource (71-71)
🔇 Additional comments (11)
packages/ui-components/src/lib/storesGeneric/cachedWritableStore.ts (1)

1-64: Well-implemented persistent store with good error handling!

This implementation of a cached writable store is solid. I particularly like:

  • Comprehensive JSDoc with clear examples
  • Proper TypeScript typing with generics
  • Robust error handling with silent fallbacks
  • Clean separation of concerns with getCache/setCache helpers

The store correctly handles localStorage persistence while gracefully degrading when localStorage is unavailable or errors occur, which is excellent for resilience.

tauri-app/src/lib/storesGeneric/fetchableStore.ts (1)

2-2: Import path change looks correct.

The update from a relative import to an absolute alias path is appropriate for the new utility location.

packages/ui-components/src/lib/index.ts (1)

120-120: Export of the new cachedWritableStore utility looks good.

The cachedWritableStore is now correctly exported alongside other stores, making it available for use throughout the application.

packages/webapp/src/routes/orders/+page.svelte (2)

5-5: Great improvement using persistent settings!

Importing settings directly from the centralized store rather than relying on page data improves maintainability and ensures user preferences persist across sessions.


14-15: Properly simplified store destructuring

The restructuring correctly removes stores that are now imported directly from the settings module, making the code cleaner and more maintainable.

packages/webapp/src/routes/vaults/+page.svelte (2)

5-6: Good implementation of persistent settings imports

These imports correctly leverage the new persistent stores for user preferences, ensuring a consistent approach across different views in the application.


18-19: Properly simplified store destructuring

The destructuring of page stores has been correctly adjusted to remove properties that are now imported from the centralized settings module.

packages/webapp/src/lib/stores/settings.ts (4)

1-23: Well-implemented settings store with proper error handling

The settings store implementation is robust with appropriate serialization, deserialization, and error handling. The JSDoc comments clearly explain the purpose and default values.


24-44: Good implementation of hideZeroBalanceVaults persistent store

The store includes proper type checking in the deserializer to ensure the returned value is always a boolean, with a sensible default of true when parsing fails.


46-66: Well-implemented showMyItemsOnly store

This store correctly implements the PR objective of preserving the user's preference for displaying only data connected to their wallet. The error handling and type checking are robust.


68-88: Properly implemented activeSubgraphs store

This store supports the PR objective of preserving active network selections. The implementation includes proper error handling with a sensible default empty object.

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

🔭 Outside diff range comments (2)
tauri-app/src/lib/storesGeneric/fetchableStore.ts (1)

45-52: 🧹 Nitpick (assertive)

Use Number.parseInt instead of global parseInt.

For consistency with the UI components package, update to use Number.parseInt here as well.

export const fetchableIntStore = (key: string, handleFetch: () => Promise<number>) =>
  fetchableStore<number>(
    key,
    0,
    handleFetch,
    (v) => v.toString(),
-    (s) => parseInt(s),
+    (s) => Number.parseInt(s),
  );
🧰 Tools
🪛 Biome (1.9.4)

[error] 51-51: Use Number.parseInt instead of the equivalent global.

ES2015 moved some globals into the Number namespace for consistency.
Safe fix: Use Number.parseInt instead.

(lint/style/useNumberNamespace)

tauri-app/src/lib/stores/settings.ts (1)

159-159: ⚠️ Potential issue

Fix logical error in condition check

There's a logic error in the condition that checks if orderbooks are undefined.

-    !$settings?.orderbooks === undefined ||
+    $settings?.orderbooks === undefined ||

The current expression first negates the result of $settings?.orderbooks (converting it to a boolean) and then compares that boolean to undefined, which is likely not the intended logic.

♻️ Duplicate comments (1)
packages/webapp/src/routes/+layout.svelte (1)

17-20: Consider making the settings synchronization reactive.

The current implementation synchronizes settings only once on component initialization. For consistency, you may want to make this synchronization reactive to handle subsequent changes to page data.

-const { settings } = $page.data.stores;
-cachedSettings.set(settings);
+$: if ($page.data.stores?.settings) {
+  cachedSettings.set($page.data.stores.settings);
+}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 33cbf62 and 144fdb0.

📒 Files selected for processing (13)
  • packages/ui-components/src/lib/index.ts (1 hunks)
  • packages/ui-components/src/lib/storesGeneric/cachedWritableStore.ts (1 hunks)
  • packages/webapp/src/routes/+layout.svelte (1 hunks)
  • packages/webapp/src/routes/orders/+page.svelte (1 hunks)
  • packages/webapp/src/routes/vaults/+page.svelte (1 hunks)
  • tauri-app/src/lib/mocks/mockConfigSource.ts (1 hunks)
  • tauri-app/src/lib/stores/settings.test.ts (0 hunks)
  • tauri-app/src/lib/stores/settings.ts (3 hunks)
  • tauri-app/src/lib/storesGeneric/cachedWritableStore.ts (0 hunks)
  • tauri-app/src/lib/storesGeneric/detailStore.ts (1 hunks)
  • tauri-app/src/lib/storesGeneric/fetchableStore.ts (1 hunks)
  • tauri-app/src/lib/storesGeneric/listStore.ts (1 hunks)
  • tauri-app/src/lib/storesGeneric/settingStore.ts (1 hunks)
💤 Files with no reviewable changes (2)
  • tauri-app/src/lib/stores/settings.test.ts
  • tauri-app/src/lib/storesGeneric/cachedWritableStore.ts
🧰 Additional context used
🧬 Code Graph Analysis (1)
tauri-app/src/lib/mocks/mockConfigSource.ts (1)
packages/ui-components/src/lib/index.ts (2)
  • mockConfigSource (141-141)
  • ConfigSource (71-71)
🪛 Biome (1.9.4)
packages/ui-components/src/lib/storesGeneric/cachedWritableStore.ts

[error] 78-78: Use Number.parseInt instead of the equivalent global.

ES2015 moved some globals into the Number namespace for consistency.
Safe fix: Use Number.parseInt instead.

(lint/style/useNumberNamespace)


[error] 115-115: Use Number.parseInt instead of the equivalent global.

ES2015 moved some globals into the Number namespace for consistency.
Safe fix: Use Number.parseInt instead.

(lint/style/useNumberNamespace)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: test
  • GitHub Check: test
  • GitHub Check: git-clean
🔇 Additional comments (15)
packages/ui-components/src/lib/storesGeneric/cachedWritableStore.ts (1)

30-64: Well-implemented localStorage persistence with good error handling.

The implementation properly handles localStorage initialization, fallback to default values, and silently ignores storage failures. This is a robust approach that ensures the application continues to function even when localStorage is unavailable.

tauri-app/src/lib/storesGeneric/fetchableStore.ts (1)

2-2: Import source updated correctly.

The import has been successfully updated to use the shared implementation from the UI components package.

tauri-app/src/lib/storesGeneric/detailStore.ts (1)

2-2: Import source updated correctly.

The import has been successfully updated to use the shared implementation from the UI components package.

tauri-app/src/lib/storesGeneric/listStore.ts (1)

6-6: Import source updated correctly.

The import has been successfully updated to use the shared implementation from the UI components package.

tauri-app/src/lib/storesGeneric/settingStore.ts (1)

2-2: Good refactoring to use the shared implementation.

The migration from a local implementation to the shared @rainlanguage/ui-components package is a positive change that promotes code reuse and simplifies maintenance.

packages/ui-components/src/lib/index.ts (1)

120-125: Well-organized exports of caching utilities.

The new export statements properly expose the cached writable store utilities for use across the application, following the established pattern in this file and organizing them in the appropriate section.

packages/webapp/src/routes/orders/+page.svelte (2)

5-5: Good switch to centralized persistent stores.

Importing the settings directly from the central store improves code organization and enables persistent user preferences across sessions.


14-15: LGTM!

The updated destructuring maintains proper code organization.

tauri-app/src/lib/mocks/mockConfigSource.ts (1)

1-37: Well-structured mock configuration for testing

The mock configuration provides a good baseline for testing with the essential components needed. It includes a network, subgraph, orderbook, deployer, metaboard, and accounts.

packages/webapp/src/routes/vaults/+page.svelte (2)

5-6: Appropriate migration to centralized settings stores

The component now properly imports settings from the centralized stores instead of relying on page data, which aligns with the PR's goal to save user preferences across sessions.


8-19: Clean destructuring of remaining page data stores

The code correctly destructures only the stores that are still needed from page data after migrating others to centralized stores.

tauri-app/src/lib/stores/settings.ts (4)

2-2: Appropriately updated import path for cached stores

The code now correctly imports the cached store utilities from the UI components package instead of local implementation.


13-14: Good test preparation

Adding imports for mock data and test utilities prepares the file for the new test suite.


277-380: Comprehensive test suite for settings reactivity

The added tests thoroughly verify that changes to the settings store correctly update dependent stores like activeAccountsItems and activeSubgraphs. The tests cover important edge cases such as removing values and changing values.


282-307: Good test hygiene with store reset

The tests properly reset all store values before each test to prevent state leakage between tests, which is a best practice for testing reactive stores.

@hardyjosh
Copy link
Contributor

@hardingjam can we also cache "Include inactive orders"? as it seems to be the last one not being cached

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 comments (1)
packages/ui-components/src/lib/components/tables/VaultsListTable.svelte (1)

96-106: 💡 Verification agent

🧩 Analysis chain

Consider implementing the "Include inactive orders" filter caching.

Based on the PR comments, there's a request to extend caching functionality to include the "Include inactive orders" filter. Since this component already interacts with the cached settings, it would be a natural place to implement that additional feature.


🌐 Web query:

What is the typical implementation pattern for toggling between active and inactive orders in React or Svelte applications?

💡 Result:

The typical implementation pattern for toggling between active and inactive orders in React or Svelte applications involves managing state to track which set of orders to display, and conditionally rendering the orders based on that state. Here's how it’s commonly done in both frameworks:

React

  1. State Management: Use useState to track whether the active or inactive orders are being displayed.
  2. Event Handler: Create a function to update the state when toggling.
  3. Conditional Rendering: Render the orders based on state.
  4. Example Pattern:
import React, { useState } from 'react';

function Orders() {
  const [showActive, setShowActive] = useState(true);

  const activeOrders = [...]; // fetch or pass active orders
  const inactiveOrders = [...]; // fetch or pass inactive orders

  return (
    <div>
      <button onClick={() => setShowActive(true)}>Active Orders</button>
      <button onClick={() => setShowActive(false)}>Inactive Orders</button>

      <ul>
        {(showActive ? activeOrders : inactiveOrders).map(order => (
          <li key={order.id}>{order.name}</li>
        ))}
      </ul>
    </div>
  );
}

Svelte

  1. Reactive Variable: Use a reactive variable to track the toggle.
  2. Event Handler: Simple functions or direct event binding to change the state.
  3. Conditional Rendering: Use {#if} blocks or ternary expressions.
  4. Example Pattern:
<script>
  let showActive = true;

  let activeOrders = [...]; // your active orders data
  let inactiveOrders = [...]; // your inactive orders data
</script>

<button on:click={() => showActive = true}>Active Orders</button>
<button on:click={() => showActive = false}>Inactive Orders</button>

<ul>
  {#each showActive ? activeOrders : inactiveOrders as order}
    <li>{order.name}</li>
  {/each}
</ul>

Common Notes:

  • Orders data can come from props, API calls, or local state.
  • This pattern can be enhanced with tabs, toggles, or buttons.
  • You can also consider memoization or derived state if the data is large or expensive to compute.

If you want, I can provide a more advanced example or include managing the data with async fetching!


🏁 Script executed:

#!/bin/bash
# Locate the VaultsListTable.svelte file and display relevant sections
FILE_PATH=$(fd VaultsListTable.svelte -x echo)
echo "File path: $FILE_PATH"
sed -n '1,200p' "$FILE_PATH"

# Search for any existing "inactive" related state or props in the codebase
rg -n "inactive" -n packages/ui-components/src/lib/components

Length of output: 7988


🏁 Script executed:

#!/bin/bash
# Inspect ListViewOrderbookFilters.svelte to see how filters and caching are implemented
FILE1=$(fd ListViewOrderbookFilters.svelte -x echo)
echo "ListViewOrderbookFilters: $FILE1"
sed -n '1,200p' "$FILE1"
echo
rg -n "Include inactive" "$FILE1"
echo
rg -n "settings\." "$FILE1"

# Inspect CheckboxActiveOrders.svelte to check its implementation
FILE2=$(fd CheckboxActiveOrders.svelte -x echo)
echo "CheckboxActiveOrders: $FILE2"
sed -n '1,200p' "$FILE2"

Length of output: 4184


Implement caching for the “Include inactive orders” toggle

Currently, the CheckboxActiveOrders control only updates the local activeOrderStatus store and isn’t persisted in your user settings, so its state is lost on reload. To align it with your other cached filters (e.g. active subgraphs), you should:

• Extend your ConfigSource type to include an optional includeInactiveOrders?: boolean field.
• In ListViewOrderbookFilters.svelte, derive a store from settings.includeInactiveOrders and wire the checkbox’s change handler to update that field.
• Update CheckboxActiveOrders.svelte to use the derived value instead of its own checked flag.

Suggested diff in ListViewOrderbookFilters.svelte:

--- a/packages/ui-components/src/lib/components/ListViewOrderbookFilters.svelte
+++ b/packages/ui-components/src/lib/components/ListViewOrderbookFilters.svelte
@@ <script lang="ts">
-import CheckboxActiveOrders from './checkbox/CheckboxActiveOrders.svelte';
+import CheckboxActiveOrders from './checkbox/CheckboxActiveOrders.svelte';
+import { derived } from 'svelte/store';
 
 export let settings: Writable<ConfigSource | undefined>;
 export let activeOrderStatus: Writable<boolean>;
 
+// Persist “include inactive orders” in settings
+const includeInactiveOrders = derived(
+  settings,
+  $settings => $settings?.includeInactiveOrders ?? false
+);
+function toggleIncludeInactiveOrders() {
+  settings.update(cfg => ({
+    ...(cfg ?? {}),
+    includeInactiveOrders: !$settings.includeInactiveOrders
+  }));
+}
 </script>
 
 {#if isOrdersPage}
   <InputOrderHash {orderHash} />
   <div class="mt-4">
-    <CheckboxActiveOrders {activeOrderStatus} />
+    <CheckboxActiveOrders
+      activeOrderStatus={includeInactiveOrders}
+      on:change={toggleIncludeInactiveOrders}
+    />
   </div>
 {/if}

And update ConfigSource in your types to include includeInactiveOrders?: boolean. This ensures the “Include inactive orders” setting is read from and written to your persistent settings store.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 33a3880 and 644d276.

📒 Files selected for processing (6)
  • packages/ui-components/src/__tests__/ListViewOrderbookFilters.test.ts (1 hunks)
  • packages/ui-components/src/lib/__mocks__/stores.ts (2 hunks)
  • packages/ui-components/src/lib/components/ListViewOrderbookFilters.svelte (1 hunks)
  • packages/ui-components/src/lib/components/tables/VaultsListTable.svelte (1 hunks)
  • packages/ui-components/src/lib/types/appStores.ts (1 hunks)
  • tauri-app/src/lib/stores/settings.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (16)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-rs-static)
  • GitHub Check: standard-tests (ubuntu-latest, test-js-bindings)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-sol-static)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-sol-test)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-rs-artifacts, true)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-sol-artifacts)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-wasm-test)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-sol-legal)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-wasm-artifacts)
  • GitHub Check: standard-tests (ubuntu-latest, ob-rs-test, true)
  • GitHub Check: Deploy-Preview
  • GitHub Check: test
  • GitHub Check: test
  • GitHub Check: build-tauri (ubuntu-22.04, true)
  • GitHub Check: test
  • GitHub Check: git-clean
🔇 Additional comments (5)
packages/ui-components/src/lib/components/ListViewOrderbookFilters.svelte (1)

22-22: Type narrowing for improved consistency.

The prop type has been narrowed from Writable<boolean | undefined> to Writable<boolean>, which aligns with the cached settings store implementation. This change improves type safety by enforcing that activeOrderStatus must always be a boolean.

packages/ui-components/src/lib/types/appStores.ts (1)

8-8: Type narrowing for improved consistency.

The store interface type has been narrowed from Writable<boolean | undefined> to Writable<boolean>, which enforces that activeOrderStatus must always be a boolean value. This change is part of the broader refactoring to standardize types across the cached settings implementation.

packages/ui-components/src/__tests__/ListViewOrderbookFilters.test.ts (1)

49-49: Test initialization aligned with new type requirements.

The test initialization has been updated to use true instead of undefined as the initial value for activeOrderStatus, which aligns with the type narrowing changes and the default value in the cached settings store.

packages/ui-components/src/lib/components/tables/VaultsListTable.svelte (1)

32-32: Type narrowing for improved consistency.

The prop type has been narrowed from Writable<boolean | undefined> to Writable<boolean>, which aligns with the cached settings store implementation. This standardizes the usage of activeOrderStatus across components.

packages/ui-components/src/lib/__mocks__/stores.ts (1)

30-31: Mock store type updated to match implementation changes

The mock store for activeOrderStatus has been appropriately updated to match the implementation changes in the actual store. The type is now strictly boolean with a default value of true.

Also applies to: 66-70

@hardyjosh hardyjosh enabled auto-merge May 9, 2025 12:02
@hardyjosh hardyjosh merged commit ddd10a9 into main May 9, 2025
17 checks passed
@coderabbitai coderabbitai bot mentioned this pull request May 11, 2025
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cache filter choices to localstorage Persist filter selections through reloads
3 participants