Skip to content

Refactor configuration counting and query key structure - #48

Merged
AlexKempen merged 7 commits into
certfrom
claude/refresh-query-key-standardization-7em2g9
Aug 30, 2026
Merged

Refactor configuration counting and query key structure#48
AlexKempen merged 7 commits into
certfrom
claude/refresh-query-key-standardization-7em2g9

Conversation

@AlexKempen

Copy link
Copy Markdown
Collaborator

Summary

This PR refactors configuration counting logic to distinguish between indexed configurations (capped at MAX_PART_NUMBER_CONFIGURATIONS) and total combinations (capped at MAX_COUNTED_CONFIGURATIONS), and restructures query keys to use a hierarchical library-scoped prefix for better cache invalidation.

Key Changes

Configuration Counting

  • Added countCombinations() function that counts all parameter combinations without the indexing cap, allowing admins to see the true configuration count even when it exceeds the indexing limit
  • Introduced MAX_COUNTED_CONFIGURATIONS constant (100,000) as a separate cap for display purposes
  • Updated InsertableParsedSection to use the new useDisplayedConfigurationCount() hook instead of receiving count as a prop
  • Changed indexing UI to show "Over 100,000" instead of "Over 10,000" when displaying total combinations
  • Updated tooltip for exceeded configurations to clarify the indexing eligibility threshold

Build Status UI

  • Replaced IndexedBadge component with ExcludedFromPropertiesIcon that shows a file icon only for cosmetic parameters
  • Simplified parameter display logic to focus on Onshape's "exclude from affecting properties" concept
  • Added special handling for assemblies in IndexingRow to indicate metadata is pulled directly from the assembly tab
  • Imported ElementType to support assembly detection

Query Key Structure

  • Refactored query keys to use hierarchical library-scoped prefixes via libraryQueryKey(libraryId)
  • Renamed libraryQueryKey() to libraryDataQueryKey() for clarity
  • Removed separate match keys (libraryQueryMatchKey(), libraryVersionQueryMatchKey(), etc.) in favor of prefix-based invalidation
  • Updated useRefreshLibrary() to invalidate the entire library prefix, simplifying cache management
  • Updated all query key consumers to use the new structure

Thumbnail Preview

  • Added useLastRenderedUrl() hook to persist the last successfully rendered image URL across configuration changes
  • Prevents fallback/placeholder images from displacing real renders when switching configurations

Testing

  • Added comprehensive tests for countCombinations() including edge cases, visibility conditions, and cap behavior
  • Verified countCombinations() agrees with countConfigurations() under the index cap

Documentation

  • Updated query-keys.ts comments to clarify the library-scoped hierarchy
  • Improved refresh.ts comments to explain the invalidation strategy

https://claude.ai/code/session_01DN1YyJcDC5UGqCoNhfUuNy

claude added 7 commits August 30, 2026 21:05
Every library-scoped query is now ["library", libraryId, <endpoint>, ...],
so useRefreshLibrary invalidates that one prefix instead of enumerating
each query's match key. Drops the *QueryMatchKey helpers (two of which
were already unused) and renames the library snapshot key to
libraryDataQueryKey, freeing libraryQueryKey to name the prefix.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DN1YyJcDC5UGqCoNhfUuNy
Opening a group replaced the whole page with a bare zero state until the
library snapshot landed, leaving no name and no way back, and reused the
home page's plural "Loading groups..." copy. The header now renders
without a group, showing a skeleton for the name and dropping the menu
until there is something to act on, so the loading and error states sit
inside the page instead of standing in for it.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DN1YyJcDC5UGqCoNhfUuNy
The spinner the header work was meant to restore was already showing;
only its wording was wrong, carried over from the home page's list.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DN1YyJcDC5UGqCoNhfUuNy
The worker stands the element default in for a configuration it has yet
to render, so changing configuration dropped the preview the user had
back to the default before the new render landed. The preview now keeps
the last real render until the one it asked for arrives; only an element
with nothing rendered yet shows the default.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DN1YyJcDC5UGqCoNhfUuNy
Assemblies pull metadata from the assembly tab, so the configuration cap
never applies to them; the indexing row now says so instead of reporting
an error an admin cannot act on.

Configurations report their real total. countConfigurations stops at the
index cap because the load path enumerates every combination, so counting
for display gets its own depth-first pass that holds one path at a time.

The per-parameter Indexed/Not indexed badge becomes an icon shown only
where Onshape excludes a parameter from affecting properties, which is
the lever on the count — quantity parameters no longer read as a state
an admin can change.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DN1YyJcDC5UGqCoNhfUuNy
Onshape's own entry needs a session and https, so there was no written
way to run the app locally; standalone mode is, and it wants three vars
rather than the README's OAuth setup.

Those vars reached the test Worker as well, where FORCE_SIGNED_IN
rewrote what the auth tests assert, so the pool no longer loads .env.

Also trims comments added over this branch to the length AGENTS.md asks
for, and drops ones the signature already gave.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DN1YyJcDC5UGqCoNhfUuNy
ACCESS_LEVEL_OVERRIDE granted the level and VITE_DEFAULT_ACCESS_LEVEL
picked the one viewed, so both had to be set to the same thing to get a
usable dev session. Wrangler puts .env on the Worker's env as well as
Vite's, so one VITE_-prefixed entry reaches both sides.

The override also outranked a real Onshape session anywhere it was set,
despite the README saying it did nothing in production. It is now gated
the way FORCE_SIGNED_IN already was, with a test that fails without it.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DN1YyJcDC5UGqCoNhfUuNy
@AlexKempen
AlexKempen merged commit 4430d7a into cert Aug 30, 2026
1 check 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