feat: initial Cutdex application
Add the Flutter video editing application with project management, media import, timeline editing, preview, AI assistance, diagnostics and settings. Include shared UI and native host packages, platform runners, application tests and release tooling. Provide usage and contribution guides, the MIT license and third-party notices. Exclude local credentials, build outputs and validation data.
This commit is contained in:
commit
27e77fff39
718 files changed
+183958
No files matched your search
@@ -0,0 +1,80 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
import '../../settings/settings_write_queue.dart';
|
||||
import 'agent_models.dart';
|
||||
import 'agent_runtime.dart';
|
||||
import 'agent_runtime_factory.dart';
|
||||
import 'agent_settings_service.dart';
|
||||
|
||||
part 'agent_settings.g.dart';
|
||||
|
||||
/// Presentation-facing state holder. Persistence and credentials are delegated
|
||||
/// to [AgentSettingsService].
|
||||
@Riverpod(keepAlive: true)
|
||||
class AgentSettings extends _$AgentSettings {
|
||||
late AgentSettingsService _service;
|
||||
final _writes = SettingsWriteQueue();
|
||||
|
||||
@override
|
||||
Future<AgentSettingsState> build() async {
|
||||
_service = ref.watch(agentSettingsServiceProvider);
|
||||
return _service.load();
|
||||
}
|
||||
|
||||
Future<void> setEnabled(bool enabled) =>
|
||||
_replace((current) => _service.setEnabled(current, enabled));
|
||||
|
||||
Future<void> setProviderEnabled(String providerId, bool enabled) => _replace(
|
||||
(current) => _service.setProviderEnabled(current, providerId, enabled),
|
||||
);
|
||||
|
||||
Future<void> selectModel(String providerId, String modelId) =>
|
||||
_replace((current) => _service.selectModel(current, providerId, modelId));
|
||||
|
||||
Future<void> upsertProvider({
|
||||
String? id,
|
||||
required String name,
|
||||
required AgentApiType apiType,
|
||||
required String baseUrl,
|
||||
required List<AgentModelSettings> models,
|
||||
String? apiKey,
|
||||
bool clearApiKey = false,
|
||||
}) => _replace(
|
||||
(current) => _service.upsertProvider(
|
||||
current,
|
||||
id: id,
|
||||
name: name,
|
||||
apiType: apiType,
|
||||
baseUrl: baseUrl,
|
||||
models: models,
|
||||
apiKey: apiKey,
|
||||
clearApiKey: clearApiKey,
|
||||
),
|
||||
);
|
||||
|
||||
Future<void> deleteProvider(String providerId) =>
|
||||
_replace((current) => _service.deleteProvider(current, providerId));
|
||||
|
||||
Future<void> _replace(
|
||||
Future<AgentSettingsState> Function(AgentSettingsState) update,
|
||||
) {
|
||||
return _writes.run(() async {
|
||||
if (!ref.mounted) return;
|
||||
final current = await future;
|
||||
if (!ref.mounted) return;
|
||||
final next = await update(current);
|
||||
if (ref.mounted) state = AsyncData(next);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Riverpod(keepAlive: true)
|
||||
FutureOr<AgentRuntime?> agentRuntime(Ref ref) async {
|
||||
final factory = ref.watch(agentRuntimeFactoryProvider);
|
||||
final settings = ref.watch(agentSettingsProvider);
|
||||
final value = settings.asData?.value;
|
||||
if (value != null) return factory.create(value);
|
||||
return factory.create(await ref.watch(agentSettingsProvider.future));
|
||||
}
|
||||
Reference in new issue
Block a user