Skip to content

refactor: admin pages on TanStack Query with the generated query options - #331

Merged
HardMax71 merged 1 commit into
mainfrom
refactor/frontend-tanstack-query
Oct 11, 2026
Merged

HardMax71 merged 1 commit into
mainfrom
refactor/frontend-tanstack-query

Conversation

@HardMax71

@HardMax71 HardMax71 commented Oct 11, 2026 •

Copy link
Copy Markdown
Owner

Part of #326. The admin pages now get their server state from TanStack Query, through the options the hey-api @tanstack/svelte-query plugin generates.

Sagas, executions, events, users and system settings read with createQuery and write with createMutation. Polling is refetchInterval, so it pauses in a hidden tab, and every filter is its own cache key, so a slow poll can't overwrite newer results. Writes invalidate what they change. pollWhileVisible and the pagination factory are deleted. Browsing events is a POST, so a getKind hook in openapi-ts.config.ts generates it as a query.

The saga search used to filter only the current page while the total counted all of them. GET /api/v1/sagas/ now takes search, an escaped case-insensitive match on saga ID, name, execution ID and error message, and the page sends it.

Queries don't retry yet. The fetch interceptor still toasts every failed request, so each retry would toast again. Moving the toasts into the query cache, turning retries on and the rest of the app (editor, settings, notifications, auth) come in the next PR.

The global test mock moved from the API index to sdk.gen.ts so the generated options call the mocks, and renderWithQueryClient and createInQueryContext give components and stores a query client. Vitest passes 1122 tests with coverage at 95.1/79.5/94.5/95.5, and backend unit, ruff, mypy and the orphan check pass. The non-k8s e2e suite passes except the 19 known k3s-only tests and the new saga search route test, which uses the same pod-created helper; the new service-level search test passes. I also ran the built frontend against a local backend in Chrome and went through all five admin pages.


Summary by cubic

Moves all five admin pages' server state to TanStack Query, using the options the hey-api @tanstack/svelte-query plugin generates. Reads use createQuery and writes use createMutation; polling is now refetchInterval, which pauses in hidden tabs, and each filter is its own cache key, so a slow poll can't overwrite newer results. This removes pollWhileVisible and the pagination factory, and the admin stores no longer track their own loading, polling, or pagination state. Writes invalidate what they change. Queries don't retry yet — the fetch interceptor toasts every failed request, so a retry would toast again; moving the toasts into the query cache and converting the rest of the app come in a follow-up.

The saga search previously filtered only the current page while the total counted all sagas. GET /api/v1/sagas/ now takes search, an escaped case-insensitive match on saga ID, name, execution ID, and error message, so search applies across all pages.

Browsing events is a read sent as POST, so a getKind hook in openapi-ts.config.ts generates it as a query. New test helpers renderWithQueryClient and createInQueryContext wrap components and stores in a query client, and the global API mock moved from the API index to sdk.gen.ts so the generated options call the mocks.

Written for commit 8754639. Summary will update on new commits.

View guided diff Turn on auto-fix

The admin stores and pages now read through createQuery and write through createMutation, using the options the hey-api TanStack plugin generates. Polling is refetchInterval, writes invalidate or refetch what they change, and pollWhileVisible and the pagination factory are gone.

The saga list takes a search parameter that matches saga ID, name, execution ID or error message on the server, so the search box covers every page instead of filtering the current one.

Queries don't retry yet, since the fetch interceptor toasts every failure. Moving the toasts into the query cache and the rest of the app comes next under #326.
@github-actions github-actions Bot added documentation Improvements or additions to documentation area: frontend Svelte UI and the generated API client labels Oct 11, 2026
@coderabbitai

coderabbitai Bot commented Oct 11, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8e18117d-9308-4fa2-b13a-9c67b2db66e5

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added area: api FastAPI routes, auth, rate limiting, settings area: execution Queue, sagas, k8s worker, pod monitor, result processor, executor pods, runtimes labels Oct 11, 2026
@sonarqubecloud

Copy link
Copy Markdown

@codecov-commenter

codecov-commenter commented Oct 11, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 94.89362% with 12 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
frontend/src/routes/admin/events/+page.svelte 84.61% 3 Missing and 1 partial ⚠️
frontend/src/routes/admin/executions/+page.svelte 81.25% 2 Missing and 1 partial ⚠️
frontend/src/routes/admin/users/+page.svelte 95.45% 0 Missing and 2 partials ⚠️
...rontend/src/lib/admin/stores/eventsStore.svelte.ts 97.36% 0 Missing and 1 partial ⚠️
frontend/src/routes/admin/sagas/+page.svelte 93.33% 1 Missing ⚠️
frontend/src/routes/admin/settings/+page.svelte 95.23% 0 Missing and 1 partial ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Flag Coverage Δ
backend-e2e 82.98% <100.00%> (+0.12%) ⬆️
backend-unit 72.34% <30.00%> (-0.03%) ⬇️
frontend-unit 87.84% <94.66%> (+0.12%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
backend/app/api/routes/saga.py 100.00% <100.00%> (ø)
backend/app/db/repositories/saga_repository.py 84.34% <100.00%> (+0.56%) ⬆️
backend/app/domain/saga/models.py 100.00% <100.00%> (ø)
backend/app/services/saga/saga_service.py 98.46% <100.00%> (+3.14%) ⬆️
...tend/src/components/admin/sagas/SagaFilters.svelte 94.44% <ø> (ø)
.../src/components/admin/users/RateLimitsModal.svelte 77.98% <100.00%> (+1.40%) ⬆️
...end/src/lib/admin/stores/executionsStore.svelte.ts 100.00% <100.00%> (+3.44%) ⬆️
frontend/src/lib/admin/stores/sagasStore.svelte.ts 100.00% <100.00%> (ø)
frontend/src/lib/query-client.ts 100.00% <100.00%> (ø)
frontend/src/routes/+layout.svelte 100.00% <100.00%> (ø)
... and 6 more

... and 2 files with indirect coverage changes

Components Coverage Δ
Backend 91.47% <100.00%> (+0.12%) ⬆️
Frontend 87.84% <94.66%> (+0.12%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@HardMax71
HardMax71 merged commit 8443b14 into main Oct 11, 2026
22 checks passed
@HardMax71
HardMax71 deleted the refactor/frontend-tanstack-query branch October 11, 2026 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: api FastAPI routes, auth, rate limiting, settings area: execution Queue, sagas, k8s worker, pod monitor, result processor, executor pods, runtimes area: frontend Svelte UI and the generated API client documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants