- 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 | 14 | } from "@t3tools/shared/model"; |
| 15 | 15 | import { getComposerProviderState } from "./components/chat/composerProviderState"; |
| 16 | 16 | import { UnifiedSettings } from "@t3tools/contracts/settings"; |
| 17 | +import * as Arr from "effect/Array"; | |
| 18 | +import * as Result from "effect/Result"; | |
| 17 | 19 | import { |
| 18 | 20 | getDefaultServerModel, |
| 19 | 21 | getProviderModels, |
| @@ -150,9 +152,9 @@ export function getAppModelOptions( · 130 unmodified lines | ||
| 150 | 152 | const options: AppModelOption[] = getProviderModels(providers, provider).map(toAppModelOption); |
| 151 | 153 | const seen = new Set(options.map((option) => option.slug)); |
| 152 | 154 | const builtInModelSlugs = new Set( |
| 153 | − getProviderModels(providers, provider) | |
| 154 | − .filter((model) => !model.isCustom) | |
| 155 | − .map((model) => model.slug), | |
| 155 | + Arr.filterMap(getProviderModels(providers, provider), (model) => | |
| 156 | + model.isCustom ? Result.failVoid : Result.succeed(model.slug), | |
| 157 | + ), | |
| 156 | 158 | ); |
| 157 | 159 | |
| 158 | 160 | // Read from the default instance's config first (that's where edits |
| @@ -198,7 +200,9 @@ export function getAppModelOptionsForInstance( · 39 unmodified lines | ||
| 198 | 200 | const options: AppModelOption[] = entry.models.map(toAppModelOption); |
| 199 | 201 | const seen = new Set(options.map((option) => option.slug)); |
| 200 | 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 | 208 | const customModels = readInstanceCustomModels(settings, entry.instanceId, entry.driverKind); |