feat: add middelwares to the ui - #202
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces support for registering and resolving generation middleware from the Genkit Dev UI. It adds a new use field to GenerateActionOptions to receive selected middleware names, resolves these names to fresh middleware instances in GenerateAction, and executes them through the wrapGenerate, wrapModel, and wrapTool chains. It also updates the registry to support typed value buckets (e.g., "middleware"), exposes these values via the reflection API endpoints (/api/values), and provides builder methods to pre-register middleware. The reviewer feedback highlights three key issues: a concurrency bug in Genkit.registerMiddlewareForDevUi due to a non-atomic check-then-act pattern, a thread-safety issue in DefaultRegistry.registerValue that can be resolved using putIfAbsent, and a potential deserialization issue in GenerateAction when converting tool inputs, suggesting the use of JsonUtils.convert(...) instead of the local objectMapper.
Description
Type of Change
Changes Made
Add middleware support to the Dev UI
Checklist
Screenshots (if applicable)
Documentation
Reviewer Notes