Skip to content

feat(v2-data-api): provider order_key, models bulk patch, hooks, cherry-in oauth#14935

Closed
jidan745le wants to merge 3 commits into
CherryHQ:v2from
jidan745le:feat/v2/data-api-providers-models-and-hooks
Closed

feat(v2-data-api): provider order_key, models bulk patch, hooks, cherry-in oauth#14935
jidan745le wants to merge 3 commits into
CherryHQ:v2from
jidan745le:feat/v2/data-api-providers-models-and-hooks

Conversation

@jidan745le
Copy link
Copy Markdown
Collaborator

What this PR does

Before this PR:

  • user_provider had no ordering column; provider order was implicit.
  • DataApi had no provider reorder / batch reorder endpoints, no /providers/:providerId/preset-metadata endpoint, and no batch PATCH /models.
  • Renderer had no useModels / useProviders hooks for the v2 data-api.
  • CherryIN OAuth service was the older variant.

After this PR:

  • user_provider.order_key (NOT NULL) is added via migration 0022, indexed, and populated by the preset seeder and v2 migrator.
  • DataApi exposes PATCH /providers/:id/order, PATCH /providers/order:batch, GET /providers/:providerId/preset-metadata, and PATCH /models (bulk update), with corresponding service-layer logic and tests.
  • Model gains isDeprecated plumbing through schema, mapping, and ModelService.
  • Renderer exposes useModels / useProviders hooks (with mutations) backed by the v2 data-api.
  • CherryINOAuthService is refactored with accompanying tests.
  • Connected service tests (Assistant / KnowledgeBase / KnowledgeItem / Message / KnowledgeOrchestration) are updated to populate order_key after the NOT NULL constraint change.

This PR is split out from feat/v2/provider-settings-v2-parallel. Intentionally excluded here (kept on the original branch for follow-up PRs):

  • packages/ui composites (ReorderableList, Sortable, PageSidePanel)
  • src/renderer/src/pages/settings/ProviderSettingsV2/**
  • i18n locale changes, generated route tree, and the provider-v2 route
  • Auxiliary work-in-progress in the parent worktree (path registry / window registry / DbService / MigrationDbService / reconcileDrizzleJournalOrderKeyDrift / etc.)

Fixes #

Why we need it and why it was done in this way

Provider ordering and the supporting endpoints are prerequisites for the upcoming Provider Settings v2 UI; landing them as a backend-only PR keeps the v2 UI PR scoped to UI/UX changes and lets reviewers focus on each layer independently.

The following tradeoffs were made:

  • The PR keeps backend changes, the matching renderer hooks, and the CherryINOAuthService refactor together to avoid stacked-PR coordination across forks (GitHub does not support cross-fork stacked bases). This trades a slightly larger diff for a self-contained, CI-passing unit.
  • The connected service test fixups are bundled with the schema change because user_provider.order_key is now NOT NULL — separating them would break CI on intermediate revisions.

The following alternatives were considered:

  • Splitting into 4–6 sub-PRs (schema / providers / seed+migrator / models / hooks / cherry-in). Rejected for now because stacked PRs from a fork all need base = CherryHQ:v2, so reviewers would have to merge in a strict order anyway.

Links to places where the discussion took place:

Breaking changes

None for end users in this PR (no UI consumes the new endpoints yet). Internal callers of userProviderTable.insert() must now provide an orderKey; all in-tree call sites have been updated.

Special notes for your reviewer

  • This branch was prepared with git restore --source=feat/v2/provider-settings-v2-parallel --pathspec-from-file=... to avoid hand-editing files.
  • The commit was created with --no-verify because the throwaway worktree did not have local dev dependencies installed; the changes themselves were not modified by this PR.
  • Pre-existing __drizzle_migrations reconciliation logic (reconcileDrizzleJournalOrderKeyDrift) is not included here — it is being tracked separately.
  • Some test files belong to other modules (Assistant / KnowledgeBase / etc.); they only adjust seed data to satisfy the new NOT NULL constraint.

Checklist

This checklist is not enforcing, but it's a reminder of items that could be relevant to every PR.
Approvers are expected to review this list.

Release note

NONE

jidan745le and others added 2 commits May 8, 2026 15:49
…ry-in oauth

Split out from feat/v2/provider-settings-v2-parallel.

Backend:

- Add user_provider.order_key column (migration 0022) and provider reorder endpoints (PATCH /providers/:id/order, PATCH /providers/order:batch)

- Add /providers/:providerId/preset-metadata endpoint via ProviderRegistryService.getProviderPresetMetadata

- Add bulk PATCH /models with isDeprecated field

- Update presetProviderSeeder and ProviderModelMigrator/Mappings to populate order_key

- Refactor CherryIN OAuth service

Renderer:

- Add useModels / useProviders hooks for v2 data-api

Tests:

- Update connected service tests (Assistant/KnowledgeBase/KnowledgeItem/Message/KnowledgeOrchestration) to populate order_key after NOT NULL constraint change

Excluded from this PR (kept in feat/v2/provider-settings-v2-parallel):

- packages/ui composites (ReorderableList, Sortable)

- src/renderer/src/pages/settings/ProviderSettingsV2/* + i18n + routes

Signed-off-by: jidan745le <420511176@qq.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Restore src/renderer/src/components/__tests__/QuickPanelView.test.tsx to its upstream/v2 baseline. The oxlint consistent-type-imports cleanup was unrelated to this PR's v2 data-api scope and remains on feat/v2/provider-settings-v2-parallel for a follow-up.

Signed-off-by: jidan745le <420511176@qq.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@jidan745le jidan745le marked this pull request as ready for review May 8, 2026 09:27
@jidan745le jidan745le requested a review from a team May 8, 2026 09:27
@jidan745le jidan745le requested a review from 0xfullex as a code owner May 8, 2026 09:27
@jidan745le jidan745le requested review from DeJeune and kangfenmao May 8, 2026 10:33
@DeJeune DeJeune added the v2 label May 8, 2026
@jidan745le jidan745le closed this May 9, 2026
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.

2 participants