setActiveModel method
Sets the active model for subsequent operations.
Automatically routes to inference or embedding based on spec type.
For inference specs, also persists modelType + fileType so the
active reference survives an app restart (#227).
Implementation
@override
void setActiveModel(ModelSpec spec) {
if (spec is InferenceModelSpec) {
_activeInferenceModel = spec;
debugPrint('✅ Set active inference model: ${spec.name}');
// Fire-and-forget — SharedPreferences write is cheap and the
// success of the operation is already reflected in memory.
unawaited(_persistActiveInferenceIdentity(spec));
} else if (spec is EmbeddingModelSpec) {
_activeEmbeddingModel = spec;
debugPrint('✅ Set active embedding model: ${spec.name}');
unawaited(_persistActiveEmbeddingIdentity(spec));
} else {
throw ArgumentError('Unknown ModelSpec type: ${spec.runtimeType}');
}
}