Repository navigation
Topic server conditioning v1 - #67
Conversation
…lements and their application, including ConditioningApplyOnEnum, ConditioningElementTypeEnum, and related models for structured conditioning logic
…epresent a collection of condition elements
…l and ConditioningModel classes; introduce ConditionEqualElement class for improved condition handling
…ioningElementTypeEnum, and introduce AreaConditionModel for enhanced condition handling in areas
…able Value property and introduce ConditionNotElement class for enhanced condition handling
…uests to the backend, including support for GET, POST, PUT, DELETE, and OPTIONS methods
…nditionModel with ElementType property for enhanced condition handling
…onditionOrElementModel to use Children property and introduce ConditionAndChildElementModel and ConditionOrChildElementModel for improved condition handling
… ConditionAndChildElementModel and ChildElementType in ConditionNotElement for consistency
…ConditionElementModel for improved flexibility and consistency
…rsion logic for improved robustness and error handling
…payload generation for conditions
… ConditionOrChildElementModel for consistency
… for handling area conditions
…ModelJsonConverter for JSON serialization
…IConditionElementModel and register condition element class maps
There was a problem hiding this comment.
Pull Request Overview
This PR implements a conditional execution system for Areas V2, adds a proxy route to avoid CORS issues, removes test files, and reactivates CI/CD workflows. Key changes include:
- Adds conditions support for Area V2 with logical operators (And, Or, Not, Equals)
- Implements a Next.js API proxy to bypass CORS restrictions
- Introduces condition nodes in the visual builder UI with diamond-shaped representation
- Removes timer-related tests and reactivates GitHub Actions workflows
Reviewed Changes
Copilot reviewed 23 out of 35 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| Server/Services/V2/Area/AreaService.cs | Adds condition verification logic and improved error handling for missing sources |
| Server/Services/V2/Area/AreaService.Conditions.cs | Implements condition evaluation functions for And/Or/Not/Equals operators |
| Server/Models/V2/*.cs | Defines condition data models and interfaces |
| Server/Converters/ConditionElementJsonConverter.cs | Implements custom JSON serialization for polymorphic condition elements |
| Server/Contexts/MongoDbContext.cs | Configures BSON serialization for condition element interface types |
| Tests/controller-tester/lib/api.ts | Updates API client to use proxy route instead of direct API calls |
| Tests/controller-tester/app/api/proxy/[...path]/route.ts | Implements Next.js API proxy to forward requests and handle CORS |
| Tests/controller-tester/app/area-v2-builder/page.tsx | Adds visual condition node builder with modal editor UI |
| .github/workflows/*.yaml | Reactivates CI/CD workflows for server and client builds |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return Task.CompletedTask; | ||
| } | ||
|
|
||
| public bool VerifyCoditions(string? source, List<ActionOutputModel> outputs, List<AreaConditionModel> conditions) |
There was a problem hiding this comment.
Corrected spelling of 'VerifyCoditions' to 'VerifyConditions'.
| { | ||
| Console.WriteLine($"Processing action for area {area.Id}"); | ||
| Console.WriteLine($"Action result: {JsonConvert.SerializeObject(actionResult)}"); | ||
| if (!VerifyCoditions(null, actionResult.Outputs ?? [], area.Conditions ?? [])) |
There was a problem hiding this comment.
Corrected spelling of 'VerifyCoditions' to 'VerifyConditions'.
| var reactionResult = await reactionInput(user, area, inputs); | ||
| // Store outputs for this reaction by its name for downstream references | ||
| if (!string.IsNullOrWhiteSpace(reaction.Name)) | ||
| if (!string.IsNullOrWhiteSpace(reaction.Name) && VerifyCoditions(reaction.Name!, reactionResult ?? [], area.Conditions ?? [])) |
There was a problem hiding this comment.
Corrected spelling of 'VerifyCoditions' to 'VerifyConditions'.
| using System.ComponentModel; | ||
| using MongoDB.Bson.Serialization.Serializers; | ||
| using System.Diagnostics; |
There was a problem hiding this comment.
These imports appear to be unused. Line 22 (System.ComponentModel), line 23 (MongoDB.Bson.Serialization.Serializers), and line 24 (System.Diagnostics) should be removed if they are not used elsewhere in the file to keep imports clean.
| var reactionInput = GetReactionInput(reaction.Type); | ||
| var inputs = reaction.Parameters?.Select(param => ConvertToReactionInput(param, outputsBySource)).ToList() ?? new List<ReactionInputModel>(); | ||
| var inputs = reaction.Parameters?.Select(param => ConvertToReactionInput(param, outputsBySource)).OfType<ReactionInputModel>().ToList() ?? []; | ||
| if (inputs.Count != 0 && inputs.Any(x => x == null)) |
There was a problem hiding this comment.
The condition inputs.Any(x => x == null) will never be true because line 297 uses OfType<ReactionInputModel>() which filters out null values. This check is redundant and unreachable. Either remove this check or verify the intended logic.
| foreach (var child in orElement.Children) | ||
| { | ||
| if (child.ElementType == null || child.Element == null) | ||
| continue; | ||
| var childFunc = GetVerifyConditionsFunction(child.ElementType ?? throw new Exception("Unexpected error")); | ||
| if (childFunc == null) | ||
| continue; | ||
| if (childFunc(source, output, child.Element ?? throw new Exception("Unexpected error"))) | ||
| return true; | ||
| } |
There was a problem hiding this comment.
This foreach loop implicitly filters its target sequence - consider filtering the sequence explicitly using '.Where(...)'.
| foreach (var condition in conditions) | ||
| { | ||
| if (condition.ElementType == null) | ||
| continue; | ||
| var output = outputs.FirstOrDefault(output => output.Name == condition.OutputName); | ||
| if (output == null) | ||
| continue; | ||
| var verifyConditions = GetVerifyConditionsFunction(condition.ElementType.Value); | ||
| if (verifyConditions == null || condition.Element == null) | ||
| continue; | ||
| if (!verifyConditions(source, output, condition.Element)) | ||
| return false; | ||
| } |
There was a problem hiding this comment.
This foreach loop implicitly filters its target sequence - consider filtering the sequence explicitly using '.Where(...)'.
| { | ||
| public static MongoClient Client { get; set; } | ||
| private static readonly object _lock = new(); | ||
| private static bool _isConfigured = false; |
There was a problem hiding this comment.
Field '_isConfigured' can be 'readonly'.
| private static bool _isConfigured = false; | |
| private static readonly bool _isConfigured = false; |
| if (output.IsList && output.Values != null) | ||
| return output.Values.Any(value => value == expected); | ||
| else | ||
| return output.Value == expected; |
There was a problem hiding this comment.
Both branches of this 'if' statement return - consider using '?' to express intent better.
| if (output.IsList && output.Values != null) | |
| return output.Values.Any(value => value == expected); | |
| else | |
| return output.Value == expected; | |
| return (output.IsList && output.Values != null) | |
| ? output.Values.Any(value => value == expected) | |
| : output.Value == expected; |
| if (string.IsNullOrEmpty(source)) | ||
| conditions = [.. conditions.Where(condition => condition.Source == null || string.Equals(condition.Source, "Action", StringComparison.OrdinalIgnoreCase))]; | ||
| else | ||
| conditions = [.. conditions.Where(condition => condition.Source == source)]; // case sensitive |
There was a problem hiding this comment.
Both branches of this 'if' statement write to the same variable - consider using '?' to express intent better.
This pull request introduces several significant updates to the CI/CD pipeline configuration and enhances MongoDB serialization for condition models. The main improvements include reactivating and updating orchestrator workflow files for both client and server, and ensuring proper BSON serialization for polymorphic condition elements in the backend.
CI/CD Pipeline Updates:
.github/workflows/ci-cd-orchestrator.client.yaml, enabling matrix builds and lint/test jobs for the frontend, with placeholders for future Docker and deployment steps..github/workflows/ci-cd-orchestrator.server.yaml, with jobs for solution creation, build, linting, unit tests, Docker build/push, image signing, deployment, and mirroring..github/workflows_deactivated/ci-cd-orchestrator.client.yamland.github/workflows_deactivated/ci-cd-orchestrator.server.yaml. [1] [2]Backend Serialization Improvements:
ConfigureBsonSerializationmethod inMongoDBContextto register discriminators and class maps for all condition element types implementingIConditionElementModel, ensuring correct BSON serialization/deserialization of polymorphic condition trees. [1] [2]API Model Handling:
Conditionsproperty from the request is assigned when creating a new Area inAreaV2Controller, supporting the new serialization logic.