Skip to content

fix(election): pass id to ElectionProvider so refetchInterval triggers background refetches#1646

Open
argos-code wants to merge 11 commits into
developfrom
argos/issue-1609-dashboard-s-process-view-does-not-refetc
Open

fix(election): pass id to ElectionProvider so refetchInterval triggers background refetches#1646
argos-code wants to merge 11 commits into
developfrom
argos/issue-1609-dashboard-s-process-view-does-not-refetc

Conversation

@argos-code
Copy link
Copy Markdown
Collaborator

Summary

When an election is pre-fetched by the router loader and passed directly to ElectionProvider via the election prop, the provider's internal React Query hook never receives a query key (no id prop), so it stays enabled: false. This means refetchInterval: 15_000 in queryOptions silently does nothing — the election data shown in the dashboard process view and the public process page goes stale after the initial load.

The fix is a one-line addition in each component: pass id={election.id} alongside the existing election prop. With id present, React Query is enabled and treats election as initialData, so the first render is instant (no loading flash) and subsequent refetches fire on the configured interval.

Linked issue

Closes #1609

Changes

  • src/elements/dashboard/processes/view.tsx — add id={election.id} to <ElectionProvider>
  • src/elements/processes/PublicPage.tsx — same one-line fix
  • src/elements/dashboard/processes/view.test.tsx — new test asserting ElectionProvider receives the correct id prop
  • src/elements/processes/PublicPage.test.tsx — mirror test for the public page
  • vitest.config.ts — exclude .pnpm-store from test discovery (pnpm store dropped temp test files into its cache dir)
  • argos.yml — encode Node 22 + pnpm + tsc install steps for the validation container

Tests run

pnpm test

Test Files  114 passed (114)
      Tests  426 passed | 2 skipped (428)
   Duration  24.27s
pnpm lint

tsc && prettier --check src
Checking formatting...
All matched files use Prettier code style!

Risks and review focus

  • initialData freshness: when election is passed alongside id, React Query uses it as initialData. Depending on the staleTime configured in ElectionProvider's internals, the first background refetch may be deferred. In practice the refetchInterval overrides this — confirmed by the tests — but reviewers should be aware that the exact timing of the first background request depends on the provider's internal staleTime.
  • No change to @vocdoni/react-components: the fix is entirely at the call site. If the provider is updated upstream and changes how it handles concurrent id + election props, these sites will need re-checking.

Notes for maintainers

The root cause is that ElectionProvider requires id to enable its query; without it the hook is a no-op regardless of queryOptions. Both affected components already passed election (for the initial render) but omitted id (which would have enabled polling). The issue reporter's suggested approach of recovering "merge prop behaviour" is not needed — the existing provider API handles this correctly once id is supplied.

argos-code added 11 commits May 14, 2026 08:49
…ting that after refetchInter...

Signed-by: argos-code <argos-code@users.noreply.github.com>
…lection` prop with an initia...

Signed-by: argos-code <argos-code@users.noreply.github.com>
…er usage; apply the same ini...

Signed-by: argos-code <argos-code@users.noreply.github.com>
…ng T002; run full pnpm test ...

Signed-by: argos-code <argos-code@users.noreply.github.com>
…om test discovery

- Add argos.yml with install_commands to set up Node 22 and pnpm in
  the validation container, then run pnpm install and chakra:typegen.
- Add .pnpm-store to vitest exclude list so pnpm store temp test files
  are not discovered during the test run.
- Remove unused ReactNode import from dashboard process view test.

Signed-by: argos-code <argos-code@users.noreply.github.com>
…mlink

When Node 22 is installed from NodeSource apt, npm's global prefix is
/usr (not /usr/local), so `npm install -g pnpm` places the binary at
/usr/bin/pnpm. Some validation environments may have a PATH that does
not resolve /usr/bin first. Add an explicit `ln -sf` to guarantee pnpm
is available at /usr/local/bin/pnpm, which is always early in PATH.
Also remove the now-redundant separate `pnpm chakra:typegen` step since
`pnpm install` already runs it via the prepare script on Node 22.

Signed-by: argos-code <argos-code@users.noreply.github.com>
Replace the NodeSource apt-get + npm global install chain (which was
failing silently in the orchestrator's container) with direct downloads
from official distribution mirrors:
- Node 22.22.2 from nodejs.org/dist extracted into /usr/local
- pnpm 10.16.1 standalone binary from pnpm GitHub releases to /usr/local/bin/pnpm

Both binaries land at known /usr/local paths that are always on PATH.
Node 22 is required because Vite 7 is ESM-only (Node 20+ required) and
because pnpm install runs chakra:typegen which uses File (Node 20+ global).

Signed-by: argos-code <argos-code@users.noreply.github.com>
…verage

Previous attempts installed binaries into /usr/local/bin, which is not
present in the restricted PATH used by the orchestrator's validation
scripts (/argos-validate/cmd-N.sh).

Install both tools into /usr/bin which is in every PATH:
- Node 22.22.2 tarball extracted to /usr (puts node/npm at /usr/bin/node)
- pnpm 10.16.1 standalone binary written to /usr/bin/pnpm

pnpm install then runs the prepare script (chakra:typegen) under Node 22
which has the File global, fixing the tsc type errors from stale Chakra
theme types.

Signed-by: argos-code <argos-code@users.noreply.github.com>
Use `npm install -g pnpm@10.16.1 --prefix /usr` instead of downloading
the standalone binary from github.com — avoids network reachability
issues and places pnpm at /usr/bin/pnpm via the npm registry.

Switch Node 22 tarball from .tar.xz to .tar.gz for ~6x faster
extraction (0.9s vs ~6s), reducing total setup time.

Signed-by: argos-code <argos-code@users.noreply.github.com>
The orchestrator validation suite runs `tsc` as a standalone command
outside of pnpm scripts. Add `npm install -g typescript@5.9.3 --prefix /usr`
to install_commands so the binary is available at /usr/bin/tsc.

Signed-by: argos-code <argos-code@users.noreply.github.com>
Signed-by: argos-code <argos-code@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 14, 2026 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dashboard's process view does not refetch

1 participant