Move editor UI into the app and release verified Core dependencies (#14)
Gitea CI / Assemble and validate CI artifacts (push) Successful in 1m47s
Gitea CI / Check code and tests (push) Successful in 7m15s
Gitea CI / Build Android APK (push) Successful in 4m6s
Gitea CI / Build Windows x64 app (push) Successful in 3m34s
Gitea CI / Audit and package Windows x64 (push) Successful in 1m29s
Gitea CI / Gitea CI passed (push) Successful in 1s
Gitea Release / Prepare draft Release (push) Failing after 8s
Gitea Release / Upload Android to draft Release (push) Skipped
Gitea Release / Upload Windows to draft Release (push) Skipped
Gitea Release / Verify and publish Release (push) Skipped
Gitea CI / Assemble and validate CI artifacts (push) Successful in 1m47s
Gitea CI / Check code and tests (push) Successful in 7m15s
Gitea CI / Build Android APK (push) Successful in 4m6s
Gitea CI / Build Windows x64 app (push) Successful in 3m34s
Gitea CI / Audit and package Windows x64 (push) Successful in 1m29s
Gitea CI / Gitea CI passed (push) Successful in 1s
Gitea Release / Prepare draft Release (push) Failing after 8s
Gitea Release / Upload Android to draft Release (push) Skipped
Gitea Release / Upload Windows to draft Release (push) Skipped
Gitea Release / Verify and publish Release (push) Skipped
This commit was merged in pull request #14.
This commit is contained in:
1 parent
abc1868550
commit
06f1c26681
452 files changed
+43806
-2329
No files matched your search
+177
-6
@@ -8,13 +8,68 @@ import 'package:cutdex/workspace/workspace_mode.dart';
|
||||
import 'package:cutdex/workspace/persistence/recent_projects.dart';
|
||||
import 'package:drift/native.dart';
|
||||
import 'package:drift/drift.dart' show Value;
|
||||
import 'package:cutdex_sdk/timeline/layout.dart';
|
||||
import 'package:cutdex_sdk/timeline/model.dart';
|
||||
import 'package:cutdex_core/timeline/layout.dart';
|
||||
import 'package:cutdex_core/timeline/model.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:sqlite3/sqlite3.dart';
|
||||
|
||||
void main() {
|
||||
for (final version in [2, 3, 4]) {
|
||||
test(
|
||||
'schema $version upgrades while preserving project preferences',
|
||||
() async {
|
||||
final directory = await Directory.systemTemp.createTemp(
|
||||
'app-view-schema-',
|
||||
);
|
||||
addTearDown(() => directory.delete(recursive: true));
|
||||
final file = File(p.join(directory.path, 'app.sqlite'));
|
||||
final current = AppDatabase(NativeDatabase(file));
|
||||
await DriftProjectViewSettingsRepository(current).save(
|
||||
'project',
|
||||
const ProjectViewSettingsData(
|
||||
propertiesOpen: true,
|
||||
timelineHeight: 280,
|
||||
),
|
||||
);
|
||||
await current.close();
|
||||
final old = sqlite3.open(file.path);
|
||||
try {
|
||||
old.execute(
|
||||
'ALTER TABLE project_view_configurations DROP COLUMN media_width',
|
||||
);
|
||||
if (version < 4) {
|
||||
old.execute(
|
||||
'ALTER TABLE appearance_configurations DROP COLUMN timeline_ruler_layout',
|
||||
);
|
||||
}
|
||||
if (version == 2) {
|
||||
old.execute(
|
||||
'ALTER TABLE appearance_configurations DROP COLUMN palette',
|
||||
);
|
||||
}
|
||||
old.userVersion = version;
|
||||
} finally {
|
||||
old.close();
|
||||
}
|
||||
final reopened = AppDatabase(NativeDatabase(file));
|
||||
addTearDown(reopened.close);
|
||||
final repository = DriftProjectViewSettingsRepository(reopened);
|
||||
final restored = await repository.load('project');
|
||||
expect(restored.propertiesOpen, isTrue);
|
||||
expect(restored.timelineHeight, 280);
|
||||
expect(restored.mediaWidth, isNull);
|
||||
await repository.save('project', restored.copyWith(mediaWidth: 380));
|
||||
expect((await repository.load('project')).mediaWidth, 380);
|
||||
expect(
|
||||
(await reopened.customSelect('PRAGMA user_version').getSingle())
|
||||
.read<int>('user_version'),
|
||||
5,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
test(
|
||||
'old app settings schema is rejected without changing its data',
|
||||
() async {
|
||||
@@ -85,13 +140,117 @@ void main() {
|
||||
expect(loaded.providers.single.models.single.id, 'model');
|
||||
});
|
||||
|
||||
test(
|
||||
'batched agent settings replace providers and all their models',
|
||||
() async {
|
||||
final database = AppDatabase(NativeDatabase.memory());
|
||||
addTearDown(database.close);
|
||||
final repository = DriftAgentSettingsRepository(database);
|
||||
await repository.save(
|
||||
AgentSettingsState(
|
||||
enabled: true,
|
||||
selectedProviderId: 'one',
|
||||
selectedModelId: 'model-0',
|
||||
revision: 1,
|
||||
providers: [
|
||||
for (final id in ['one', 'two'])
|
||||
AgentProviderSettings(
|
||||
id: id,
|
||||
name: id,
|
||||
apiType: 'openAiChatCompletions',
|
||||
baseUrl: 'https://example.com/v1',
|
||||
credentialId: 'credential-$id',
|
||||
models: [
|
||||
for (var index = 0; index < 50; index++)
|
||||
AgentModelSettings(
|
||||
id: 'model-$index',
|
||||
contextWindow: 32000 + index,
|
||||
maxOutputTokens: 4096,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
final saved = await repository.load();
|
||||
expect(saved.providers, hasLength(2));
|
||||
for (final provider in saved.providers) {
|
||||
expect(provider.models, hasLength(50));
|
||||
expect(
|
||||
provider.models.singleWhere((m) => m.id == 'model-49').contextWindow,
|
||||
32049,
|
||||
);
|
||||
expect(provider.credentialId, 'credential-${provider.id}');
|
||||
}
|
||||
final replacement = saved.copyWith(
|
||||
revision: 2,
|
||||
selectedModelId: 'replacement',
|
||||
providers: [
|
||||
saved.providers.first.copyWith(
|
||||
models: const [AgentModelSettings(id: 'replacement')],
|
||||
),
|
||||
],
|
||||
);
|
||||
await repository.save(replacement);
|
||||
expect(await repository.load(), replacement);
|
||||
await repository.save(const AgentSettingsState(revision: 3));
|
||||
expect(await repository.load(), const AgentSettingsState(revision: 3));
|
||||
expect(await database.select(database.agentModels).get(), isEmpty);
|
||||
},
|
||||
);
|
||||
|
||||
test(
|
||||
'a failed agent model batch rolls back the whole configuration',
|
||||
() async {
|
||||
final database = AppDatabase(NativeDatabase.memory());
|
||||
addTearDown(database.close);
|
||||
final repository = DriftAgentSettingsRepository(database);
|
||||
const saved = AgentSettingsState(
|
||||
enabled: true,
|
||||
selectedProviderId: 'provider',
|
||||
selectedModelId: 'model',
|
||||
revision: 1,
|
||||
providers: [
|
||||
AgentProviderSettings(
|
||||
id: 'provider',
|
||||
name: 'Provider',
|
||||
apiType: 'openAiChatCompletions',
|
||||
baseUrl: 'https://example.com/v1',
|
||||
models: [AgentModelSettings(id: 'model')],
|
||||
),
|
||||
],
|
||||
);
|
||||
await repository.save(saved);
|
||||
final invalid = saved.copyWith(
|
||||
enabled: false,
|
||||
revision: 2,
|
||||
providers: [
|
||||
saved.providers.single.copyWith(
|
||||
models: const [
|
||||
AgentModelSettings(id: 'duplicate'),
|
||||
AgentModelSettings(id: 'duplicate'),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
await expectLater(
|
||||
repository.save(invalid),
|
||||
throwsA(isA<SqliteException>()),
|
||||
);
|
||||
expect(await repository.load(), saved);
|
||||
final retry = saved.copyWith(enabled: false, revision: 2);
|
||||
await repository.save(retry);
|
||||
expect(await repository.load(), retry);
|
||||
},
|
||||
);
|
||||
|
||||
test('typed app repositories share one Drift database', () async {
|
||||
final database = AppDatabase(NativeDatabase.memory());
|
||||
addTearDown(database.close);
|
||||
expect(
|
||||
(await database.customSelect('PRAGMA user_version').getSingle())
|
||||
.read<int>('user_version'),
|
||||
4,
|
||||
5,
|
||||
);
|
||||
|
||||
final appearance = DriftAppearanceSettingsRepository(database);
|
||||
@@ -194,11 +353,16 @@ void main() {
|
||||
final projectView = DriftProjectViewSettingsRepository(database);
|
||||
await projectView.save(
|
||||
'two',
|
||||
const ProjectViewSettingsData(propertiesOpen: true, timelineHeight: 280),
|
||||
const ProjectViewSettingsData(
|
||||
propertiesOpen: true,
|
||||
timelineHeight: 280,
|
||||
mediaWidth: 360,
|
||||
),
|
||||
);
|
||||
final projectValue = await projectView.load('two');
|
||||
expect(projectValue.propertiesOpen, isTrue);
|
||||
expect(projectValue.timelineHeight, 280);
|
||||
expect(projectValue.mediaWidth, 360);
|
||||
|
||||
final timelineView = DriftTimelineViewSettingsRepository(database);
|
||||
await timelineView.save(
|
||||
@@ -343,8 +507,10 @@ void main() {
|
||||
sidebarWidth: 300,
|
||||
),
|
||||
);
|
||||
await DriftProjectViewSettingsRepository(first)
|
||||
.save('project', const ProjectViewSettingsData(propertiesOpen: true));
|
||||
await DriftProjectViewSettingsRepository(first).save(
|
||||
'project',
|
||||
const ProjectViewSettingsData(propertiesOpen: true, mediaWidth: 380),
|
||||
);
|
||||
await DriftTimelineViewSettingsRepository(first).save(
|
||||
'project',
|
||||
'timeline',
|
||||
@@ -392,6 +558,11 @@ void main() {
|
||||
.propertiesOpen,
|
||||
isTrue,
|
||||
);
|
||||
expect(
|
||||
(await DriftProjectViewSettingsRepository(reopened).load('project'))
|
||||
.mediaWidth,
|
||||
380,
|
||||
);
|
||||
final timeline = await DriftTimelineViewSettingsRepository(reopened)
|
||||
.load('project', 'timeline');
|
||||
expect(timeline.activeSequenceId, SequenceId('sequence'));
|
||||
|
||||
Reference in new issue
Block a user