clearActiveInferenceIdentity method

  1. @override
Future<void> clearActiveInferenceIdentity()
override

Clears the active inference identity (in-memory spec + persisted prefs).

Has a default body (rather than being abstract) so adding it does not break third-party ModelFileManager implementers at compile time — but the default THROWS rather than silently succeeding: a "clear" that quietly does nothing would leave a stale active identity persisted (a silent failure). Implementers that persist active state must override it.

Implementation

@override
Future<void> clearActiveInferenceIdentity() async {
  await _ensureInitialized();
  try {
    final prefs = await SharedPreferences.getInstance();
    await prefs.remove(PreferencesKeys.activeInferenceModelType);
    await prefs.remove(PreferencesKeys.activeInferenceFileType);
    await prefs.remove(PreferencesKeys.activeInferenceFilename);
    await prefs.remove(PreferencesKeys.activeInferenceSource);
    _activeInferenceModel = null;
  } catch (e) {
    gemmaLog('[ModelManager] clearActiveInferenceIdentity failed: $e');
    rethrow;
  }
  gemmaLog('Active inference identity cleared');
}