mirror of
https://github.com/davidkaya/aryx.git
synced 2026-07-30 08:28:48 +02:00
feat: allow deletion of built-in orchestration patterns
Remove the restriction that prevented users from deleting built-in patterns (those with IDs prefixed 'pattern-'). Built-in patterns are intended as starting points, not permanent fixtures. Changes: - Add deletedBuiltinPatternIds field to WorkspaceState to track which built-in patterns the user has removed - Update mergePatterns to skip deleted built-ins during workspace load, preventing them from being re-added - Remove the isBuiltinPattern guard from AryxAppService.deletePattern; when a built-in is deleted, its ID is recorded in the tracking list - Enable the delete button in SettingsPanel and PatternEditor for all patterns (keep the 'Built-in pattern' label for context) - Add 3 tests covering built-in deletion, custom deletion, and selectedPatternId fallback Users can still restore deleted built-ins via workspace reset. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -59,6 +59,47 @@ function requirePattern(workspace: WorkspaceState, mode: PatternDefinition['mode
|
||||
return pattern;
|
||||
}
|
||||
|
||||
describe('AryxAppService deletePattern', () => {
|
||||
test('deletes a built-in pattern and tracks its ID', async () => {
|
||||
const workspace = createWorkspaceSeed();
|
||||
const builtinPattern = requirePattern(workspace, 'sequential');
|
||||
const service = createService(workspace);
|
||||
|
||||
const result = await service.deletePattern(builtinPattern.id);
|
||||
|
||||
expect(result.patterns.find((p) => p.id === builtinPattern.id)).toBeUndefined();
|
||||
expect(result.deletedBuiltinPatternIds).toContain(builtinPattern.id);
|
||||
});
|
||||
|
||||
test('deletes a custom pattern without tracking its ID', async () => {
|
||||
const workspace = createWorkspaceSeed();
|
||||
const customPattern: PatternDefinition = {
|
||||
...requirePattern(workspace, 'single'),
|
||||
id: 'custom-pattern',
|
||||
name: 'My Custom Pattern',
|
||||
};
|
||||
workspace.patterns.push(customPattern);
|
||||
const service = createService(workspace);
|
||||
|
||||
const result = await service.deletePattern('custom-pattern');
|
||||
|
||||
expect(result.patterns.find((p) => p.id === 'custom-pattern')).toBeUndefined();
|
||||
expect(result.deletedBuiltinPatternIds ?? []).not.toContain('custom-pattern');
|
||||
});
|
||||
|
||||
test('selects first remaining pattern when the active pattern is deleted', async () => {
|
||||
const workspace = createWorkspaceSeed();
|
||||
const targetPattern = requirePattern(workspace, 'single');
|
||||
workspace.selectedPatternId = targetPattern.id;
|
||||
const service = createService(workspace);
|
||||
|
||||
const result = await service.deletePattern(targetPattern.id);
|
||||
|
||||
expect(result.selectedPatternId).toBe(result.patterns[0]?.id);
|
||||
expect(result.selectedPatternId).not.toBe(targetPattern.id);
|
||||
});
|
||||
});
|
||||
|
||||
describe('AryxAppService savePattern', () => {
|
||||
test('preserves a provided custom graph instead of re-syncing it', async () => {
|
||||
const workspace = createWorkspaceSeed();
|
||||
|
||||
Reference in New Issue
Block a user