[PR #32355] refactor(web): harden constrained nuqs parsers and infer query-state types #33691

Closed
opened 2026-02-21 20:53:43 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/32355

State: closed
Merged: Yes


Stacked PR Context

  • Base branch: refactor/datasets-document-list-nuqs-migration (PR #32339, base main)
  • What the base branch already changed:
    • migrated dataset document-list URL state to nuqs
    • switched document detail back-navigation to useSearchParams
    • introduced shared NuqsTestingAdapter test helpers and updated related tests/docs

This PR only contains incremental hardening on top of the base branch.

Summary

  • replace loosely typed string parsers with constrained nuqs parsers for URL-state fields with finite domains:
    • apps list category
    • tools provider category
    • plugin page tab
    • account setting modal action/tab
  • keep runtime callbacks safe where UI components emit raw strings (TabSlider, TabSliderNew) by adding explicit guards
  • infer document list query type from parser map instead of manually maintaining DocumentListQuery
  • infer marketplace search params type from parser map and use it in server hydration loader path

Why

  • reduce type drift between parser behavior and TypeScript declarations
  • make constrained query params self-documenting and compile-time enforceable
  • keep stacked changes easy to review by separating base migration from incremental parser/type tightening

Validation

  • pre-commit checks passed (eslint --fix, type-check:tsgo, unit-test check)
  • pnpm --dir web test hooks/use-query-params.spec.tsx app/components/tools/__tests__/provider-list.spec.tsx app/components/apps/__tests__/list.spec.tsx app/components/plugins/plugin-page/__tests__/context.spec.tsx app/components/plugins/plugin-page/__tests__/index.spec.tsx
  • pnpm --dir web test app/components/datasets/documents/hooks/__tests__/use-document-list-query-state.spec.tsx app/components/datasets/documents/detail/__tests__/index.spec.tsx __tests__/datasets/document-management.test.tsx
  • pnpm --dir web test app/components/plugins/marketplace/__tests__/atoms.spec.tsx app/components/plugins/marketplace/__tests__/state.spec.tsx app/components/plugins/marketplace/__tests__/plugin-type-switch.spec.tsx app/components/plugins/marketplace/__tests__/sticky-search-and-switch-wrapper.spec.tsx
  • pnpm --dir web type-check:tsgo
**Original Pull Request:** https://github.com/langgenius/dify/pull/32355 **State:** closed **Merged:** Yes --- ## Stacked PR Context - **Base branch**: `refactor/datasets-document-list-nuqs-migration` (PR #32339, base `main`) - **What the base branch already changed**: - migrated dataset document-list URL state to `nuqs` - switched document detail back-navigation to `useSearchParams` - introduced shared `NuqsTestingAdapter` test helpers and updated related tests/docs This PR only contains incremental hardening on top of the base branch. ## Summary - replace loosely typed string parsers with constrained `nuqs` parsers for URL-state fields with finite domains: - apps list category - tools provider category - plugin page tab - account setting modal action/tab - keep runtime callbacks safe where UI components emit raw strings (`TabSlider`, `TabSliderNew`) by adding explicit guards - infer document list query type from parser map instead of manually maintaining `DocumentListQuery` - infer marketplace search params type from parser map and use it in server hydration loader path ## Why - reduce type drift between parser behavior and TypeScript declarations - make constrained query params self-documenting and compile-time enforceable - keep stacked changes easy to review by separating base migration from incremental parser/type tightening ## Validation - pre-commit checks passed (`eslint --fix`, `type-check:tsgo`, unit-test check) - `pnpm --dir web test hooks/use-query-params.spec.tsx app/components/tools/__tests__/provider-list.spec.tsx app/components/apps/__tests__/list.spec.tsx app/components/plugins/plugin-page/__tests__/context.spec.tsx app/components/plugins/plugin-page/__tests__/index.spec.tsx` - `pnpm --dir web test app/components/datasets/documents/hooks/__tests__/use-document-list-query-state.spec.tsx app/components/datasets/documents/detail/__tests__/index.spec.tsx __tests__/datasets/document-management.test.tsx` - `pnpm --dir web test app/components/plugins/marketplace/__tests__/atoms.spec.tsx app/components/plugins/marketplace/__tests__/state.spec.tsx app/components/plugins/marketplace/__tests__/plugin-type-switch.spec.tsx app/components/plugins/marketplace/__tests__/sticky-search-and-switch-wrapper.spec.tsx` - `pnpm --dir web type-check:tsgo`
yindo added the pull-request label 2026-02-21 20:53:43 -05:00
yindo closed this issue 2026-02-21 20:53:43 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#33691