Skip to content

fix(provider-models): delete an individual synced model, persistently (#3199) - #3211

Closed
diegosouzapw wants to merge 1 commit into
release/v3.8.11from
fix/3199-llamacpp-model-delete
Closed

diegosouzapw wants to merge 1 commit into
release/v3.8.11from
fix/3199-llamacpp-model-delete

Conversation

@diegosouzapw

Copy link
Copy Markdown
Collaborator

Closes #3199

Synced (fetched) models were authoritative with no per-model delete, so individual llama-cpp models couldn't be removed (or re-appeared on re-fetch). Adds removeSyncedAvailableModel + marks the id hidden so re-import skips it; DELETE now removes from both custom and synced sets. No migration (reuses the existing hidden-model marker).

Test: tests/unit/synced-model-delete-3199.test.ts. Thanks @tjengbudi.

…eep it deleted (#3199)

Synced (fetched) models were authoritative with no per-model delete, so
individual llama-cpp models couldn't be removed (or re-appeared on re-fetch).
Add removeSyncedAvailableModel + mark the id hidden so re-import skips it;
the DELETE route now removes from both custom and synced sets.

Co-authored-by: tjengbudi <tjengbudi@users.noreply.github.com>
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: aaa0d87abe

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/lib/db/models.ts
Comment on lines +719 to +721
const normalizedModels = normalizeSyncedAvailableModels(models).filter(
(m) => !getModelIsHidden(providerId, m.id)
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Return filtered models after dropping hidden IDs

When a refresh/auto-fetch runs after a synced model was deleted, this filter prevents the hidden ID from being written back to SQLite, but persistDiscoveredModels() still returns its pre-filtered normalized input and src/app/api/providers/[id]/models/route.ts treats any non-empty discoveredModels as a successful API result and returns the raw upstream models. In that scenario the just-deleted model still appears in the /api/providers/[id]/models?refresh=true response whenever the upstream advertises it, and if all discovered IDs are hidden the route also skips the intended local fallback; return/use the filtered list from replaceSyncedAvailableModelsForConnection() or filter the API response before deciding it is non-empty.

Useful? React with 👍 / 👎.

@diegosouzapw

Copy link
Copy Markdown
Collaborator Author

Superseded — #3204 already landed the core synced-model delete on release/v3.8.11. Re-doing as a minimal follow-up (mark deleted synced model hidden + skip it on re-import) so the deletion persists across auto-fetch.

@diegosouzapw
diegosouzapw deleted the fix/3199-llamacpp-model-delete branch June 5, 2026 05:53
@kilo-code-bot

kilo-code-bot Bot commented Jun 5, 2026 •

Copy link
Copy Markdown

Code Review Summary

Status: Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
src/lib/db/models.ts 719-721 Performance concern: replaceSyncedAvailableModelsForConnection now calls getModelIsHidden for each incoming model in the .filter() callback, resulting in O(n) synchronous database queries. For large model catalogs, this could significantly slow down the sync path. Consider batching the hidden-model lookup (read all compat overrides once, then filter in-memory).
src/lib/db/models.ts 790-797 Type mismatch: The rows array is typed as Array<{ key: string; value: string }>, but getKeyValue can return { key: null, value: null }. The null checks using k && value !== null are correct, but the type annotation is misleading and could cause confusion for future maintainers.
Other Observations (not in diff)

Issues found in unchanged code that cannot receive inline comments:

File Line Issue
src/lib/db/models.ts 781-832 The new removeSyncedAvailableModel function does not call removeModelCompatOverride after removing a synced model, leaving orphaned compat entries if they exist. When a synced model is deleted (especially when marked hidden), any existing compat overrides for that model should also be cleaned up to prevent stale data accumulation.
Files Reviewed (4 files)
  • src/lib/db/models.ts - 2 issues
  • src/app/api/provider-models/route.ts - no issues
  • src/app/api/providers/[id]/models/route.ts - no issues
  • tests/unit/synced-model-delete-3199.test.ts - no issues

Reviewed by laguna-m.1-20260312:free · 2,261,871 tokens

Comment thread src/lib/db/models.ts
const targetId = toNonEmptyString(modelId);
if (!targetId) return false;

const rows: Array<{ key: string; value: string }> = [];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: Type annotation mismatch — rows is typed as Array<{ key: string; value: string }>, but getKeyValue returns { key: string | null; value: string | null }. The null checks on lines 796-797 correctly handle this, but the type annotation is misleading and could cause confusion for future maintainers. Consider using Array<{ key: string; value: string } | { key: null; value: null }> or a more precise type.

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.

1 participant