Skip to content

Conversation

michalczukm
Copy link
Contributor

@michalczukm michalczukm commented May 14, 2025

Description

Solving the #37

Screen.Recording.2025-05-14.at.02.40.13.mov

Type of change

  • New feature (non-breaking change which adds functionality)

Please see #37

Notes

Query params format

I considered two options for the data format in the URL's query parameters:

  1. Transform for readability, like rules=REACT&VUE (use directory keys for clarity).
  2. Retain the Zustand state shape.

I chose option 2, keeping the Zustand state shape because:

  • It includes the version field, allowing for data migration using Zustand's persistence features if needed.
  • It's the simplest solution.

URL query params length limitations

Since URL parameters can be lengthy, I've compressed them using LZ-String. The package is "complete," so there's no active development, including the absence of an ESM version, which I find acceptable.

Hydration of the zustand state

To overcome the hydration issues, I've decided to show a placeholder if there is a need for hydration (if we have any state in URL params).
Placeholder is plain "Loading..." (I will put it in translations.ts or add some nice skeleton - but rooting for your feedback on the approach first 😊)

More context in tldr; form - Zustand, and state management is a client thing. Since there are hacky ways of enabling it on server-side, it is not recommended.

More on that: zustand main readme and the whole thread it points to. With some interesting way of doing it 😅

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

  • Unit Tests - Added some new ones
  • E2E Tests - The new ones have not been added yet. Rooting for initial feedback first

Important Note for Fork-Based PRs

  • TODO MM: setup the GHA for running the E2E tests in my fork

If you're submitting a PR from a forked repository, please note that E2E tests require specific repository-level environment (integration) and secrets to be set up. These are described in .env.example and include:

PUBLIC_ENV_NAME=integration
SUPABASE_URL=###
SUPABASE_PUBLIC_KEY=###

E2E_USERNAME_ID=###
E2E_USERNAME=###
E2E_PASSWORD=###

Please ensure these are properly configured in your fork's repository settings under "Secrets and variables" → "Actions" before running E2E tests.

@psmyrdek
Copy link
Collaborator

Great job, esp. with the concept of persisting versioned state that allows future migration. That was my main concerns so I appreciate it's already handled. Thanks!

@all-contributors add @michalczukm for code

Copy link
Contributor

@psmyrdek

I've put up a pull request to add @michalczukm! 🎉

@psmyrdek psmyrdek merged commit bc95a45 into przeprogramowani:master May 15, 2025
3 of 5 checks passed
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.

2 participants