Files
openchamber/packages/ui/src/lib/modelVariants.ts
T
Bohdan Triapitsyn 2740c7b3a2 feat(projects): pin a thinking level next to a project's model
A project could pin the model new chats start on, but not the level to
run it at: the default cascade dropped any variant as soon as a project
model won, and only ever considered the global one — which belongs to
the global model.

Projects now carry `defaultVariant` alongside `defaultModel`, stored and
sanitized only next to that model, and the cascade passes it through.
Both controls sit in one "Defaults for new chats" group laid out like the
Sessions defaults, and the level appears only for models that offer them.
2026-08-22 20:31:31 +03:00

21 lines
771 B
TypeScript

import type { Provider } from '@opencode-ai/sdk/v2';
type ProviderModel = Provider['models'][string];
/**
* Names of the thinking levels a model exposes, empty when it has none.
*
* The SDK's model type does not describe `variants`, so the shape is asserted
* here once instead of at every call site that offers the levels.
*/
export const modelVariantNames = (model: ProviderModel | undefined): string[] => {
if (!model) {
return [];
}
// SAFETY: the payload types `variants` as an optional object whose keys are
// the variant names. Only the key set is read, and it is returned as strings,
// so no caller depends on the value shape.
const variants = (model as { variants?: object }).variants;
return variants ? Object.keys(variants) : [];
};