Skip to content

fix(provider): remove deprecated laoshi provider - #1485

Merged
zerob13 merged 4 commits into
devfrom
fix/remove-laoshi-provider
Apr 17, 2026
Merged

fix(provider): remove deprecated laoshi provider#1485
zerob13 merged 4 commits into
devfrom
fix/remove-laoshi-provider

Conversation

@yyhhyyyyyy

@yyhhyyyyyy yyhhyyyyyy commented Apr 17, 2026

Copy link
Copy Markdown
Collaborator

fix(provider): remove deprecated laoshi provider

Summary by CodeRabbit

  • Chores
    • Removed built-in support for laoshi, astraflow, and astraflow‑cn; deprecated providers and related stored model selections (including preferred model entries) will be automatically removed on startup.
    • Deeplink playground and installer builder examples no longer include laoshi.
  • Bug Fixes
    • Legacy model/vision selections are reconciled into current presets to avoid broken agent defaults.
  • Tests
    • Added automated tests covering cleanup and reconciliation flows.

@coderabbitai

coderabbitai Bot commented Apr 17, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Added detection and removal of deprecated builtin providers and model-selection settings (including preferredModel), migrated legacy builtin agent selections into current presets when appropriate, and removed three builtin providers (astraflow, astraflow-cn, laoshi) from defaults.

Changes

Cohort / File(s) Summary
ConfigPresenter logic
src/main/presenter/configPresenter/index.ts
Added deprecated provider IDs and model-setting keys; new normalization/comparison helpers; exports removeDeprecatedBuiltinProviders() and getDeprecatedProviderModelSelectionKeysToClear(); added reconcileLegacyBuiltinAgentSelections(), cleanupDeprecatedBuiltinAgentSelections(), cleanupDeprecatedBuiltinProviders() and integrated cleanup during init and repo attach.
Default providers
src/main/presenter/configPresenter/providers.ts
Removed builtin provider entries for astraflow, astraflow-cn, and laoshi from DEFAULT_PROVIDERS.
Deeplink types
src/shared/providerDeeplink.ts
Removed 'laoshi' from SUPPORTED_PROVIDER_INSTALL_CUSTOM_TYPES (and derived types/sets/guards).
Tests
test/main/presenter/configPresenter/deprecatedProviderCleanup.test.ts
New Vitest suite covering removal helpers, detection of deprecated model-selection keys, reconciliation, and cleanup flows (including emitted CONFIG_EVENTS.SETTING_CHANGED).
Manual test page
test/manual/deeplink-playground.html
Removed 'laoshi' from builtin provider examples and custom provider type examples used by the deeplink playground.

Sequence Diagram(s)

sequenceDiagram
  participant AppInit as App Init
  participant Config as ConfigPresenter
  participant Store as Persisted Store
  participant Repo as AgentRepository
  participant Bus as EventBus

  AppInit->>Config: initialize()
  Config->>Store: getProviders(), get model-selection settings
  Store-->>Config: providers[], settings
  Config->>Config: removeDeprecatedBuiltinProviders()
  Config->>Store: setProviders(filteredProviders) 
  Config->>Config: getDeprecatedProviderModelSelectionKeysToClear(settings)
  loop for each clearedKey
    Config->>Store: delete clearedKey
    Config->>Bus: emit CONFIG_EVENTS.SETTING_CHANGED (clearedKey, undefined)
  end
  AppInit->>Repo: attach repository
  Repo->>Config: setAgentRepository()
  Config->>Config: reconcileLegacyBuiltinAgentSelections()
  alt legacy selections copied
    Config->>Store: set builtin preset values
    Config->>Bus: emit CONFIG_EVENTS.SETTING_CHANGED (as needed)
  end
  Config->>Config: cleanupDeprecatedBuiltinAgentSelections()
  Config->>Store: update builtin presets to null if deprecated
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

codex

Suggested reviewers

  • zerob13

Poem

🐰 I hopped through providers, found some old hay,
Tossed out laoshi and astraflow along the way.
I cleared stale model keys, sent pings with a wink,
Migrated old presets so nothing will sink,
Tests hop after me — now the config can play.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically identifies the main change: removing the deprecated laoshi provider. It directly matches the primary objective across multiple files (providers.ts, providerDeeplink.ts, test file, and manual test page).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/remove-laoshi-provider

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 and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
test/main/presenter/configPresenter/deprecatedProviderCleanup.test.ts (1)

80-141: Solid coverage of the happy path — consider adding an idempotency / no-op case.

The current suite verifies one full cleanup pass. A small additional case where getProviders() returns no deprecated entries and all selections already point to live providers would lock in two useful invariants: setProviders is not called, and eventBus.sendToMain is not fired. Cheap insurance against future regressions in the early-exit branches.

💡 Suggested extra case
it('is a no-op when no deprecated providers or selections are present', () => {
  const selectionStore = new Map<string, unknown>([
    ['defaultModel', { providerId: 'openai', modelId: 'gpt-4o' }]
  ])
  const store = {
    get: vi.fn((key: string) => selectionStore.get(key)),
    delete: vi.fn()
  }
  const getProviders = vi.fn().mockReturnValue([createProvider('openai')])
  const setProviders = vi.fn()

  const presenter = Object.assign(Object.create(ConfigPresenter.prototype), {
    store,
    getProviders,
    setProviders
  })

  ;(
    presenter as ConfigPresenter & { cleanupDeprecatedBuiltinProviders: () => void }
  ).cleanupDeprecatedBuiltinProviders()

  expect(setProviders).not.toHaveBeenCalled()
  expect(store.delete).not.toHaveBeenCalled()
  expect(eventBus.sendToMain).not.toHaveBeenCalled()
})
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/main/presenter/configPresenter/deprecatedProviderCleanup.test.ts` around
lines 80 - 141, Add a new unit test for
ConfigPresenter.cleanupDeprecatedBuiltinProviders that asserts
idempotency/no-op: create a selectionStore where selections point to live
providers (e.g., providerId 'openai'), mock getProviders to return only live
providers, and supply spies for setProviders and store.delete; call
cleanupDeprecatedBuiltinProviders and assert
setProviders.not.toHaveBeenCalled(), store.delete.not.toHaveBeenCalled(), and
eventBus.sendToMain.not.toHaveBeenCalled() to ensure early-exit behavior is
preserved.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/main/presenter/configPresenter/index.ts`:
- Around line 947-966: Existing cleanup only removes deprecated selections from
the flat store in cleanupDeprecatedBuiltinProviders(), but persisted selections
inside the builtin DeepChat agent remain; add a new method (e.g.,
cleanupDeprecatedBuiltinAgentSelections) that calls getBuiltinDeepChatConfig(),
checks defaultModelPreset, assistantModel, and visionModel against
DEPRECATED_BUILTIN_PROVIDER_IDS, builds a partial DeepChatAgentConfig with those
fields nulled when deprecated, and calls updateBuiltinDeepChatConfig(updates) if
any changes are needed; invoke this new cleanup from setAgentRepository()
immediately after
initializeUnifiedAgents()/migrateLegacyDefaultVisionModelToBuiltinAgent() so
agent-stored deprecated selections are sanitized when the repository attaches.

---

Nitpick comments:
In `@test/main/presenter/configPresenter/deprecatedProviderCleanup.test.ts`:
- Around line 80-141: Add a new unit test for
ConfigPresenter.cleanupDeprecatedBuiltinProviders that asserts
idempotency/no-op: create a selectionStore where selections point to live
providers (e.g., providerId 'openai'), mock getProviders to return only live
providers, and supply spies for setProviders and store.delete; call
cleanupDeprecatedBuiltinProviders and assert
setProviders.not.toHaveBeenCalled(), store.delete.not.toHaveBeenCalled(), and
eventBus.sendToMain.not.toHaveBeenCalled() to ensure early-exit behavior is
preserved.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d9376aa7-a85c-4f92-886a-b95d6b2a515e

📥 Commits

Reviewing files that changed from the base of the PR and between f0a91b7 and 31def7b.

📒 Files selected for processing (5)
  • src/main/presenter/configPresenter/index.ts
  • src/main/presenter/configPresenter/providers.ts
  • src/shared/providerDeeplink.ts
  • test/main/presenter/configPresenter/deprecatedProviderCleanup.test.ts
  • test/manual/deeplink-playground.html
💤 Files with no reviewable changes (1)
  • src/main/presenter/configPresenter/providers.ts

Comment thread src/main/presenter/configPresenter/index.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/main/presenter/configPresenter/index.ts (1)

262-274: Consider normalizing selection.providerId for consistency with sibling helpers.

isDeprecatedBuiltinProviderId (Line 204-207) and isDeprecatedBuiltinModelSelection (Line 209-218) both normalize provider IDs via normalizeKnownProviderId (lowercases/trims/resolves aliases) before checking against DEPRECATED_BUILTIN_PROVIDER_IDS. In contrast, getDeprecatedProviderModelSelectionKeysToClear does a raw deprecatedProviderIdSet.has(selection.providerId), so any persisted entry with different casing, surrounding whitespace, or an alias would slip past the flat-store cleanup even though the agent-level cleanup would catch it. Using the same normalization here would make the two cleanup passes symmetric.

♻️ Proposed refactor
 export const getDeprecatedProviderModelSelectionKeysToClear = (
   settings: Partial<
     Record<ProviderModelSettingKey, { providerId: string; modelId: string } | undefined>
   >,
   deprecatedProviderIds: readonly string[] = DEPRECATED_BUILTIN_PROVIDER_IDS
 ): ProviderModelSettingKey[] => {
-  const deprecatedProviderIdSet = new Set(deprecatedProviderIds)
-
   return DEPRECATED_PROVIDER_MODEL_SETTING_KEYS.filter((key) => {
     const selection = settings[key]
-    return isModelSelection(selection) && deprecatedProviderIdSet.has(selection.providerId)
+    return isDeprecatedBuiltinModelSelection(selection, deprecatedProviderIds)
   })
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/presenter/configPresenter/index.ts` around lines 262 - 274,
getDeprecatedProviderModelSelectionKeysToClear currently compares
selection.providerId raw against deprecatedProviderIdSet, causing mismatches for
differing case/whitespace/aliases; update this function to normalize provider
IDs the same way as
isDeprecatedBuiltinProviderId/isDeprecatedBuiltinModelSelection by calling
normalizeKnownProviderId on selection.providerId (and/or pre-normalizing
deprecatedProviderIds into the set) before checking membership; reference
getDeprecatedProviderModelSelectionKeysToClear, normalizeKnownProviderId,
DEPRECATED_PROVIDER_MODEL_SETTING_KEYS, and isModelSelection to locate and make
the change so the flat-store cleanup mirrors the agent-level cleanup.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/main/presenter/configPresenter/index.ts`:
- Around line 262-274: getDeprecatedProviderModelSelectionKeysToClear currently
compares selection.providerId raw against deprecatedProviderIdSet, causing
mismatches for differing case/whitespace/aliases; update this function to
normalize provider IDs the same way as
isDeprecatedBuiltinProviderId/isDeprecatedBuiltinModelSelection by calling
normalizeKnownProviderId on selection.providerId (and/or pre-normalizing
deprecatedProviderIds into the set) before checking membership; reference
getDeprecatedProviderModelSelectionKeysToClear, normalizeKnownProviderId,
DEPRECATED_PROVIDER_MODEL_SETTING_KEYS, and isModelSelection to locate and make
the change so the flat-store cleanup mirrors the agent-level cleanup.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 60b812a2-2213-4464-9c69-761216c8d0cc

📥 Commits

Reviewing files that changed from the base of the PR and between c85f6ef and 89c70f2.

📒 Files selected for processing (2)
  • src/main/presenter/configPresenter/index.ts
  • test/main/presenter/configPresenter/deprecatedProviderCleanup.test.ts

@zerob13
zerob13 merged commit 1ec8f2d into dev Apr 17, 2026
3 checks passed
@zhangmo8
zhangmo8 deleted the fix/remove-laoshi-provider branch April 21, 2026 03:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants