cloneProfile method

Future<LlmConfig> cloneProfile(
  1. String id, {
  2. String? newName,
})

Clones a profile and appends it to the profiles list.

Implementation

Future<LlmConfig> cloneProfile(String id, {String? newName}) async {
  final idx = _llmConfigs.indexWhere((c) => c.profileId == id || c.id == id);
  final source = idx != -1 ? _llmConfigs[idx] : _llmConfig;
  final cloned = source.clone(newName: newName);
  _llmConfigs.add(cloned);
  await _storage.saveLlmConfigs(_llmConfigs, selectedId: _selectedLlmId);
  notifyListeners();
  return cloned;
}