- Deduplicate terminal IDs and favorite model slugs with trim-aware iteration - Use effect-based filtering for local branch and built-in model lists - Switch stable array handling to non-mutating `toSorted`
Showing the changes to apps/web/src/modelSelection.ts (1 of 8 files). Show all
Unified · Split
| @@ -14,6 +14,8 @@ import { · 13 unmodified lines | |||
| 14 | } from "@t3tools/shared/model"; | 14 | } from "@t3tools/shared/model"; |
| 15 | import { getComposerProviderState } from "./components/chat/composerProviderState"; | 15 | import { getComposerProviderState } from "./components/chat/composerProviderState"; |
| 16 | import { UnifiedSettings } from "@t3tools/contracts/settings"; | 16 | import { UnifiedSettings } from "@t3tools/contracts/settings"; |
| 17 | import * as Arr from "effect/Array"; | ||
| 18 | import * as Result from "effect/Result"; | ||
| 17 | import { | 19 | import { |
| 18 | getDefaultServerModel, | 20 | getDefaultServerModel, |
| 19 | getProviderModels, | 21 | getProviderModels, |
| @@ -150,9 +152,9 @@ export function getAppModelOptions( · 130 unmodified lines | |||
| 150 | const options: AppModelOption[] = getProviderModels(providers, provider).map(toAppModelOption); | 152 | const options: AppModelOption[] = getProviderModels(providers, provider).map(toAppModelOption); |
| 151 | const seen = new Set(options.map((option) => option.slug)); | 153 | const seen = new Set(options.map((option) => option.slug)); |
| 152 | const builtInModelSlugs = new Set( | 154 | const builtInModelSlugs = new Set( |
| 153 | getProviderModels(providers, provider) | 155 | Arr.filterMap(getProviderModels(providers, provider), (model) => |
| 154 | .filter((model) => !model.isCustom) | 156 | model.isCustom ? Result.failVoid : Result.succeed(model.slug), |
| 155 | .map((model) => model.slug), | 157 | ), |
| 156 | ); | 158 | ); |
| 157 | 159 | ||
| 158 | // Read from the default instance's config first (that's where edits | 160 | // Read from the default instance's config first (that's where edits |
| @@ -198,7 +200,9 @@ export function getAppModelOptionsForInstance( · 39 unmodified lines | |||
| 198 | const options: AppModelOption[] = entry.models.map(toAppModelOption); | 200 | const options: AppModelOption[] = entry.models.map(toAppModelOption); |
| 199 | const seen = new Set(options.map((option) => option.slug)); | 201 | const seen = new Set(options.map((option) => option.slug)); |
| 200 | const builtInModelSlugs = new Set( | 202 | const builtInModelSlugs = new Set( |
| 201 | entry.models.filter((model) => !model.isCustom).map((model) => model.slug), | 203 | Arr.filterMap(entry.models, (model) => |
| 204 | model.isCustom ? Result.failVoid : Result.succeed(model.slug), | ||
| 205 | ), | ||
| 202 | ); | 206 | ); |
| 203 | 207 | ||
| 204 | const customModels = readInstanceCustomModels(settings, entry.instanceId, entry.driverKind); | 208 | const customModels = readInstanceCustomModels(settings, entry.instanceId, entry.driverKind); |