Skip to content

feat: localStorage for dashboards/saved searches in LOCAL mode#1822

Draft
teeohhem wants to merge 4 commits intomainfrom
tom/localstorage-for-localmode
Draft

feat: localStorage for dashboards/saved searches in LOCAL mode#1822
teeohhem wants to merge 4 commits intomainfrom
tom/localstorage-for-localmode

Conversation

@teeohhem
Copy link
Contributor

No description provided.

@changeset-bot
Copy link

changeset-bot bot commented Feb 27, 2026

⚠️ No Changeset found

Latest commit: e8d1980

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Feb 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hyperdx-v2-oss-app Ready Ready Preview, Comment Feb 27, 2026 6:07pm

Request Review

@github-actions
Copy link
Contributor

github-actions bot commented Feb 27, 2026

E2E Test Results

All tests passed • 75 passed • 4 skipped • 856s

Status Count
✅ Passed 75
❌ Failed 0
⚠️ Flaky 0
⏭️ Skipped 4

Tests ran across 4 shards in parallel.

View full report →

@github-actions
Copy link
Contributor

PR Review

✅ Overall this is a clean, well-structured refactor. A few minor items worth noting:

  • ⚠️ Weak ID entropy in localStore.ts:31: Math.abs(hashCode(Math.random().toString())).toString(16) uses a 32-bit hash (~2.1B values). Collision risk is low for small local datasets, but consider crypto.randomUUID() or Date.now().toString(36) + Math.random().toString(36).slice(2) for better uniqueness.

  • ⚠️ set() method on createEntityStore is dead code — defined at localStore.ts:68 but never called by any consumer. Remove it or it'll cause confusion about intended usage.

  • ℹ️ Behavioral change in source loading: Old getLocalSources() returned env-var defaults when no connection was configured (guarded by connections.length > 0 && store.has(key)). New localSources.getAll() removes the connection dependency — sources always load from localStorage once written. Intentional, but worth documenting or testing explicitly if the "reset sources on connection delete" behavior was relied upon.

  • Bug fix: Old useCreateSource returned the existing source without persisting the update to localStorage (silent no-op). New code correctly calls localSources.update(). Good catch.

  • Bug fix: useDashboard was previously calling hdxServer directly without respecting IS_LOCAL_MODE. Now fixed via fetchDashboards.

🤖 Generated with Claude Code

@github-actions
Copy link
Contributor

PR Review

  • ⚠️ @full-stack tag removed from all E2E tests → If CI uses this tag to route tests to full-stack environments, removing it changes which environments these tests run in. Intentional? Should be confirmed that the tests now pass without a full backend (since they test localStorage-backed local mode).

  • ⚠️ createEntityStore.getAll() ignores defaults when key exists as [] (localStore.ts:19) → If store.has(key) is true but the stored value is an empty array, getDefaultItems() is never called. This means if a user previously saved an empty sources list, they'll never see the HDX_LOCAL_DEFAULT_SOURCES env var defaults. May be intentional (user explicitly cleared sources), but worth documenting.

  • ⚠️ Weak ID generation (localStore.ts:31) → Math.abs(hashCode(Math.random().toString())).toString(16) produces only ~31 bits of entropy. Collision is unlikely in practice for local use but consider crypto.randomUUID() for stronger uniqueness.

  • createEntityStore is a clean abstraction - good consolidation of the duplicated localStorage CRUD patterns.

  • useCreateSource bug fix: old code returned early without persisting the updated source; new code correctly calls localSources.update().

  • ✅ Cache invalidation via onSuccess is preserved for all mutation paths in local mode.

</div>
) : null}
</>
)}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

looks scary, but it's just removal of IS_LOCAL_MODE checks

}
return hdxServer('dashboards').json<Dashboard[]>();
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

just an abstraction of logic out of the query function

{},
async ({ page }) => {
/**
* Verifies that updating a saved search with additional filters
Copy link
Contributor Author

Choose a reason for hiding this comment

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

these tests can now run in both local mode and full stack mode

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.

1 participant