Explorer: three-state facet index status fixes permanent dash on slow connections (#313 P0)#316
Open
rdhyee wants to merge 1 commit into
Open
Explorer: three-state facet index status fixes permanent dash on slow connections (#313 P0)#316rdhyee wants to merge 1 commit into
rdhyee wants to merge 1 commit into
Conversation
…n slow connections (isamplesorg#313 P0) window.__facetIndexReady was a single boolean meaning BOTH "still loading" and "failed to load", so on a slow connection the facet-count UI showed the same "—" dash for the entire ~20-80s cold-boot window as it would for a genuine, permanent load failure — indistinguishable to the user. Replace it with window.__facetIndexStatus ('pending' | 'ready' | 'failed'): - 'pending' (initial state): show "Loading…", not the dash. - 'ready': real cross-filtered counts render, same as before. - 'failed' (preflight check failed, or the query threw): show the "—" dash + existing tooltip, permanent for the session until refresh — matching today's failure-case behavior exactly. The pending-vs-failed UI decision is extracted to a pure function, facetCountsDisplayState() in assets/js/explorer-utils.js, alongside the existing extracted-pure-logic modules (issue isamplesorg#249 pattern) and covered by unit tests in tests/unit/explorer-utils.test.mjs. window.__facetIndexReady is removed (not aliased) — the only two read/write sites were both in explorer.qmd and are updated in this commit; no other file in the repo referenced it. This is P0 of the isamplesorg#313 joint Claude+Codex mitigation plan. P1 (lighter boot manifest), P3 (decouple from masks scan), and P6 (Firefox CI) are separate follow-up work. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XEtSoXjsKtnYWQ7yS8mGRo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On slow connections, the Explorer's facet-count UI showed a permanent "—" dash (meant to mean "can't compute a trustworthy count") even when the facet index was still downloading — not actually broken, just not done yet. Root cause: a single boolean,
window.__facetIndexReady, was used to mean BOTH "still loading" and "failed to load," so during the ~20-80s cold-boot window beforesample_facet_indexfinishes downloading, the UI couldn't distinguish "wait, it's coming" from "this broke, don't expect a count." This was diagnosed and posted as a comment on #313.This PR fixes that by replacing the boolean with a real three-state machine,
window.__facetIndexStatus:'pending'(initial state) — the index is still loading → the UI now shows "Loading…", not the dash.'ready'— loaded and validated → real cross-filtered counts render, exactly as before.'failed'— a preflight check failed (schema version, generation mismatch, coverage mismatch) or the query threw → the UI shows the "—" dash + the existing "Count unavailable for this filter combination" tooltip, permanent for the session until refresh — matching today's behavior for the genuine-failure case.The pending-vs-failed decision is extracted into a pure function,
facetCountsDisplayState(status, res)inassets/js/explorer-utils.js, following the same closure-free "pure logic extracted to ES modules" pattern already used in this file (issue #249, PR3) — dynamically imported intoexplorer.qmd's OJS runtime and unit-tested directly under Node.window.__facetIndexReadyis removed, not kept as a backward-compat alias: there were only two read/write sites and both were inexplorer.qmd(the boot/load cell that set it, andapplyMaskIndexCounts()that read it), both updated in this commit. A repo-wide grep confirmed no other file referenced it, so an alias wasn't needed for safety.This is P0 of the #313 joint Claude+Codex mitigation plan (P0+P1+P3+P6 revised). P1 (lighter boot manifest), P3 (decoupling the facet-index preflight from the masks scan), and P6 (Firefox CI) are separate follow-up PRs, NOT included here.
Relates to #313 (not closing it — the other mitigations are still pending).
Test plan
tests/unit/explorer-utils.test.mjscoverage forfacetCountsDisplayState(): pending→'pending'(Loading…), failed→'unavailable'(dash+tooltip), and the query-failed ('unavailable'fromapplyMaskIndexCounts) case for every status.npm run test:unit— all 17 tests pass (8 pre-existing + 4 new, no regressions).quarto render explorer.qmd --to htmlsucceeds, confirming the edited{ojs}boot-sequence cell is syntactically valid and the new code is present in the compiled output.pendingwindow end-to-end would mean booting the full DuckDB-WASM app and delaying thesample_facet_indexparquet fetch viapage.route()(a pattern that exists intests/playwright/facet-tree.spec.js, but only against a local data mirror gated behindFACET_TREE_LOCAL=1, with ~90s timeouts). The existingmarkFacetCountsUnavailable()dash path it.self has zero Playwright coverage today, so the unit test on the extracted pure decision function keeps this PR's coverage depth consistent with the rest of the facet-count UI rather than introducing new test infra as a side effect of a UI bugfix. Manual verification (DevTools network throttling, per Need to explore what browser/operating system/bandwidth combinations the Explore works and does not work in #313's repro steps) is still the recommended manual check before merge.🤖 Generated with Claude Code