Feat/server#2620
Conversation
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds a Next.js A2UI server (LLM provider, Mastra agent wrapper, catalog, prompt builder, validator, service, CORS helpers, and HTTP routes) and updates the playground to call and stream responses from that live agent instead of using mocks. ChangesA2UI Server Implementation and Playground Integration
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 12
🧹 Nitpick comments (2)
packages/genui/server/agent/a2ui-prompt.ts (1)
8-10: ⚡ Quick winUse
A2UI_PROTOCOL_VERSIONeverywhere to avoid prompt/version drift.
"v0.9"is duplicated across multiple template blocks instead of reusing the exported constant, which makes protocol upgrades error-prone.🔧 Proposed refactor
-export const A2UI_PROTOCOL_VERSION = 'v0.9'; +export const A2UI_PROTOCOL_VERSION = 'v0.9'; -const PROTOCOL_OVERVIEW = `# A2UI (Agent-to-UI) Protocol v0.9 +const PROTOCOL_OVERVIEW = `# A2UI (Agent-to-UI) Protocol ${A2UI_PROTOCOL_VERSION} ... -Every message MUST be a top-level JSON object with the field "version": "v0.9" +Every message MUST be a top-level JSON object with the field "version": "${A2UI_PROTOCOL_VERSION}" ... -2. Each element MUST include "version": "v0.9". +2. Each element MUST include "version": "${A2UI_PROTOCOL_VERSION}". ... - "version": "v0.9", + "version": "${A2UI_PROTOCOL_VERSION}",Also applies to: 19-20, 70-70, 96-96, 129-129
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/genui/server/agent/a2ui-prompt.ts` around lines 8 - 10, The template strings in this module hardcode the protocol string "v0.9" instead of using the exported constant A2UI_PROTOCOL_VERSION, which risks drift; update PROTOCOL_OVERVIEW and all other template blocks (the multi-line template constants that currently include "v0.9") to interpolate the canonical constant (e.g., use `${A2UI_PROTOCOL_VERSION}` inside the template literals) so every place references the single exported A2UI_PROTOCOL_VERSION; ensure the exported constant name is unchanged and that all occurrences (including any other templates around PROTOCOL_OVERVIEW, and other prompt blocks) are updated to use the constant.packages/genui/server/agent/a2ui-agent.ts (1)
23-32: ⚡ Quick winReplace
unknownAPI surface and double-cast with direct method type references.The current
unknowntypes andas unknown as A2UIAgentcast bypass TypeScript's strict type checking, masking potential Mastra API drift as runtime failures instead of compile-time errors.Reference
Agent['generate']andAgent['stream']directly in the interface—both are stable, public instance methods onAgentfrom@mastra/core/agentand are safe to extract as method types in exported interfaces. This eliminates the type escape hatch while maintaining full compatibility.Suggested changes
export interface A2UIAgent { - generate: ( - messages: unknown, - options?: A2UIAgentRunOptions, - ) => unknown; - stream: ( - messages: unknown, - options?: A2UIAgentRunOptions, - ) => unknown; + generate: Agent['generate']; + stream: Agent['stream']; } - const agent = new Agent({ + const agent = new Agent({ id: 'a2ui-agent', name: 'A2UIAgent', instructions, model: buildModel(model), - }) as unknown as A2UIAgent; + });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/genui/server/agent/a2ui-agent.ts` around lines 23 - 32, The exported A2UIAgent interface currently uses unknown for method signatures which hides type mismatches; update its generate and stream method types to reference the concrete method signatures Agent['generate'] and Agent['stream'] (importing Agent from '@mastra/core/agent' if not already) and keep the existing A2UIAgentRunOptions for the options parameter, removing any double-cast usages like "as unknown as A2UIAgent" so the interface and any implementations are checked against the real Agent method types at compile time.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@eslint.config.js`:
- Around line 477-491: Remove the duplicate ESLint configuration block that
matches files: 'packages/genui/server/**/*.{ts,tsx}' and
'{agent,app,service}/**/*.{ts,tsx}' (the block that sets rules like
'@typescript-eslint/no-redundant-type-constituents' and the various
'@typescript-eslint/no-unsafe-*' rules and
'n/no-unsupported-features/node-builtins' to 'off'); keep the original
occurrence (lines 186-203) and delete this repeated block (lines 477-491) so the
rules appear only once.
- Around line 186-203: The file pattern {agent,app,service}/**/*.{ts,tsx} is
incorrect (those dirs live under packages/genui/server) and should be removed
from the ESLint overrides that include the pattern; keep only
'packages/genui/server/**/*.{ts,tsx}' in both override blocks, and if you decide
to consolidate the two similar override objects, merge them into a single
override for 'packages/genui/server/**/*.{ts,tsx}' while preserving all unique
rules (e.g., keep settings for
'@typescript-eslint/no-redundant-type-constituents', the various
'@typescript-eslint/no-unsafe-*' rules, 'dot-notation',
'n/file-extension-in-import', and 'n/no-unsupported-features/node-builtins') so
no rule is lost.
In `@packages/genui/a2ui-playground/lynx-src/a2ui/App.tsx`:
- Around line 42-55: Replace the manual built-ins array (ALL_BUILTINS and the
catalogEntry(...) calls) with the standard catalog registration import from
'@lynx-js/a2ui-reactlynx/catalog/all'; remove or stop using the handcrafted
CatalogInput list and catalogEntry references in App.tsx, import the catalog/all
module which performs registration for Text, Image, Row, Column, List, Card,
Button, Divider, CheckBox, RadioGroup, and ensure any code that referenced
ALL_BUILTINS now relies on the global/registered catalog provided by the
imported module.
In `@packages/genui/a2ui-playground/src/pages/AIChatPage.tsx`:
- Around line 517-539: Replace the inline phone/iframe JSX with the
MobilePreview component: when renderUrl is present render <MobilePreview>
instead of the div.phoneWrap block, passing the renderUrl (or src) and the
encoded payload per the control-panel contract, and forward previewFrameRef and
handlePreviewLoad to MobilePreview so it can attach the iframe ref and onLoad
handler; remove the hardcoded phoneFrame/phoneIframe elements and ensure
MobilePreview receives any needed className/props used for styling and preview
behavior.
- Around line 79-83: The code currently returns the raw fromQuery value (from
URLSearchParams(window.location.search).get('a2uiEndpoint')) without validating
it; change this to validate the provided a2uiEndpoint before accepting it by
parsing it into a URL and allowing it only if its origin matches
window.location.origin or it exactly matches an entry in a dev allowlist (e.g.,
ALLOWED_A2UI_ENDPOINTS / process.env.DEV_A2UI_ENDPOINTS); update the logic
around the fromQuery early return so it only returns the value after that
validation and otherwise ignores the query param and falls back to the existing
default.
In `@packages/genui/server/agent/a2ui-validator.ts`:
- Around line 271-278: The validation is using a single global providedSet built
from providedPaths so a provided path from one surface can satisfy checks for a
different surface; change the logic to scope provided paths by surfaceId: when
iterating allPaths, filter providedPaths to the same surfaceId as the current
allPath entry (or build a Map<surfaceId, Set> of provided paths) and then
perform the matching using that per-surface set instead of the global
providedSet; update references to providedSet, providedPaths, and the loop over
allPaths accordingly (e.g., inside the loop use the per-surface set or lookup by
surfaceId before doing the .some(...) match).
In `@packages/genui/server/agent/openai-provider.ts`:
- Around line 82-85: Replace the fuzzy regex detection for official OpenAI hosts
with robust URL hostname checking: parse baseURL (prepend "https://" if missing)
and set isOfficial to true only when the parsed hostname strictly equals
"api.openai.com"; handle parse failures by treating as non-official. Update the
isOfficial assignment (used to pick the default api via api = opts.api ??
env.OPENAI_API_STYLE ?? (isOfficial ? 'responses' : 'chat')) so it no longer
uses the regex and ensures compatFetch is not bypassed for non-official hosts.
In `@packages/genui/server/app/a2ui/action/route.ts`:
- Around line 77-83: The route is calling service.getConversation(body.threadId)
which lazily creates conversations; add a non-mutating check (e.g.,
peekConversation(threadId) or hasConversation(threadId)) to A2UIAgentService and
use it here to verify existence before calling getConversation; specifically,
add peekConversation/hasConversation to A2UIAgentService (returning boolean or
the existing convo without creating state), change the route in route.ts to call
that check first and only call getConversation(body.threadId) after existence is
confirmed so invalid threadIds do not allocate memory.
In `@packages/genui/server/app/a2ui/cors.ts`:
- Around line 39-46: resolveAllowedOrigin currently returns the literal string
'null' for disallowed origins which causes Access-Control-Allow-Origin: null to
be sent; change resolveAllowedOrigin to return undefined (or a union type string
| undefined) for disallowed origins instead of 'null', update its signature and
all call sites (e.g., the code that sets the Access-Control-Allow-Origin header
around the other usage at line ~53) to only set the header when the function
returns a defined string so that the header is omitted for rejected origins.
Ensure types/returns and any tests are updated accordingly.
In `@packages/genui/server/package.json`:
- Around line 1-27: Add the missing packageManager field to this package.json by
inserting a "packageManager": "pnpm@<root-version>" entry immediately after the
existing "version" property; ensure you use the exact pnpm version declared in
the workspace root package.json and keep JSON formatting consistent with
existing fields (refer to the "packageManager" field name and the "version"
property to locate where to add it).
- Around line 14-17: Update the package.json dependencies to use Zod v4 by
replacing the "zod": "^3.25.76" entry with the appropriate Zod 4 version (e.g.,
"zod": "4.4.3") and add the missing packageManager field at top-level of this
package.json with the exact string from the root spec (e.g., "packageManager":
"pnpm@11.0.8+sha512..."); modify the dependency line named "zod" and add the
top-level "packageManager" key accordingly so the package aligns with project
guidelines.
In `@packages/genui/server/service/a2ui-agent.ts`:
- Around line 83-85: The cacheKey construction (variable cacheKey) incorrectly
collapses all non-empty opts.apiKey values into a single bucket ('k'), allowing
agents created with one caller's apiKey to be reused by others; change the cache
key to incorporate a unique identifier for the API key (either the raw
opts.apiKey or a secure hash/fingerprint of it) rather than the constant 'k', so
include opts.apiKey (or hashed(opts.apiKey)) along with opts.baseURL, opts.model
and opts.catalog?.id when building cacheKey to ensure agents are not shared
across different keys.
---
Nitpick comments:
In `@packages/genui/server/agent/a2ui-agent.ts`:
- Around line 23-32: The exported A2UIAgent interface currently uses unknown for
method signatures which hides type mismatches; update its generate and stream
method types to reference the concrete method signatures Agent['generate'] and
Agent['stream'] (importing Agent from '@mastra/core/agent' if not already) and
keep the existing A2UIAgentRunOptions for the options parameter, removing any
double-cast usages like "as unknown as A2UIAgent" so the interface and any
implementations are checked against the real Agent method types at compile time.
In `@packages/genui/server/agent/a2ui-prompt.ts`:
- Around line 8-10: The template strings in this module hardcode the protocol
string "v0.9" instead of using the exported constant A2UI_PROTOCOL_VERSION,
which risks drift; update PROTOCOL_OVERVIEW and all other template blocks (the
multi-line template constants that currently include "v0.9") to interpolate the
canonical constant (e.g., use `${A2UI_PROTOCOL_VERSION}` inside the template
literals) so every place references the single exported A2UI_PROTOCOL_VERSION;
ensure the exported constant name is unchanged and that all occurrences
(including any other templates around PROTOCOL_OVERVIEW, and other prompt
blocks) are updated to use the constant.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 9ccf0763-9af8-4a38-b7fb-71c96adabe04
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (22)
.gitignoreeslint.config.jspackages/genui/a2ui-playground/lynx-src/a2ui/App.tsxpackages/genui/a2ui-playground/src/pages/AIChatPage.tsxpackages/genui/a2ui-playground/src/styles.csspackages/genui/server/agent/a2ui-agent.tspackages/genui/server/agent/a2ui-catalog.tspackages/genui/server/agent/a2ui-prompt.tspackages/genui/server/agent/a2ui-validator.tspackages/genui/server/agent/openai-provider.tspackages/genui/server/app/a2ui/action/route.tspackages/genui/server/app/a2ui/chat/route.tspackages/genui/server/app/a2ui/cors.tspackages/genui/server/app/a2ui/health/route.tspackages/genui/server/app/a2ui/reset/route.tspackages/genui/server/app/a2ui/stream/route.tspackages/genui/server/app/layout.tsxpackages/genui/server/next-env.d.tspackages/genui/server/next.config.mjspackages/genui/server/package.jsonpackages/genui/server/service/a2ui-agent.tspackages/genui/server/tsconfig.json
8b3ac32 to
5872207
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/genui/server/agent/a2ui-validator.ts`:
- Around line 234-245: The handler is treating updateDataModel entries without a
value as valid (making omitted path default to '/' and falsely satisfying
validations); update the logic around updateDataModel to explicitly reject
entries that omit the value field: check that the parsed updateDataModel has a
defined value (e.g., !== undefined) before computing basePath or calling
flattenProvidedPaths, and if value is missing, return/throw a validation error
(or otherwise mark the message invalid) instead of pushing entries into
providedPaths for surfaceId (sId).
- Around line 37-84: The top-level message schemas (CreateSurfaceMessage,
UpdateComponentsMessage, UpdateDataModelMessage, DeleteSurfaceMessage) are
currently non-strict and can silently accept payloads containing multiple action
keys; update each top-level z.object(...) that defines these schemas to be
strict by chaining .strict() on the outer z.object so that extraneous action
keys cause validation to fail and malformed payloads are rejected.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 8f6e9dac-4051-4506-90f5-3d631b8d2740
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (22)
.gitignoreeslint.config.jspackages/genui/a2ui-playground/lynx-src/a2ui/App.tsxpackages/genui/a2ui-playground/src/pages/AIChatPage.tsxpackages/genui/a2ui-playground/src/styles.csspackages/genui/server/agent/a2ui-agent.tspackages/genui/server/agent/a2ui-catalog.tspackages/genui/server/agent/a2ui-prompt.tspackages/genui/server/agent/a2ui-validator.tspackages/genui/server/agent/openai-provider.tspackages/genui/server/app/a2ui/action/route.tspackages/genui/server/app/a2ui/chat/route.tspackages/genui/server/app/a2ui/cors.tspackages/genui/server/app/a2ui/health/route.tspackages/genui/server/app/a2ui/reset/route.tspackages/genui/server/app/a2ui/stream/route.tspackages/genui/server/app/layout.tsxpackages/genui/server/next-env.d.tspackages/genui/server/next.config.mjspackages/genui/server/package.jsonpackages/genui/server/service/a2ui-agent.tspackages/genui/server/tsconfig.json
✅ Files skipped from review due to trivial changes (3)
- packages/genui/server/next-env.d.ts
- .gitignore
- packages/genui/server/tsconfig.json
🚧 Files skipped from review as they are similar to previous changes (18)
- packages/genui/server/next.config.mjs
- packages/genui/server/package.json
- packages/genui/a2ui-playground/lynx-src/a2ui/App.tsx
- packages/genui/server/agent/a2ui-agent.ts
- packages/genui/server/agent/openai-provider.ts
- packages/genui/server/app/layout.tsx
- eslint.config.js
- packages/genui/server/app/a2ui/action/route.ts
- packages/genui/server/app/a2ui/health/route.ts
- packages/genui/server/app/a2ui/reset/route.ts
- packages/genui/server/app/a2ui/stream/route.ts
- packages/genui/server/agent/a2ui-catalog.ts
- packages/genui/server/agent/a2ui-prompt.ts
- packages/genui/a2ui-playground/src/styles.css
- packages/genui/a2ui-playground/src/pages/AIChatPage.tsx
- packages/genui/server/app/a2ui/chat/route.ts
- packages/genui/server/app/a2ui/cors.ts
- packages/genui/server/service/a2ui-agent.ts
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/genui/a2ui-playground/lynx-src/a2ui/App.tsx (1)
25-34:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winRemove unused manifest imports.
These catalog manifest imports are no longer referenced after switching to the
catalogEntryhelper, yet they remain in the import list.🧹 Proposed fix
-import buttonManifest from '@lynx-js/a2ui-reactlynx/catalog/Button/catalog.json'; -import cardManifest from '@lynx-js/a2ui-reactlynx/catalog/Card/catalog.json'; -import checkBoxManifest from '@lynx-js/a2ui-reactlynx/catalog/CheckBox/catalog.json'; -import columnManifest from '@lynx-js/a2ui-reactlynx/catalog/Column/catalog.json'; -import dividerManifest from '@lynx-js/a2ui-reactlynx/catalog/Divider/catalog.json'; -import imageManifest from '@lynx-js/a2ui-reactlynx/catalog/Image/catalog.json'; -import listManifest from '@lynx-js/a2ui-reactlynx/catalog/List/catalog.json'; -import radioGroupManifest from '@lynx-js/a2ui-reactlynx/catalog/RadioGroup/catalog.json'; -import rowManifest from '@lynx-js/a2ui-reactlynx/catalog/Row/catalog.json'; -import textManifest from '@lynx-js/a2ui-reactlynx/catalog/Text/catalog.json';🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/genui/a2ui-playground/lynx-src/a2ui/App.tsx` around lines 25 - 34, The file App.tsx still imports unused manifest symbols (buttonManifest, cardManifest, checkBoxManifest, columnManifest, dividerManifest, imageManifest, listManifest, radioGroupManifest, rowManifest, textManifest) after migrating to the catalogEntry helper; remove these unused imports from the top of App.tsx to eliminate dead code and unused-import warnings and ensure only the active catalogEntry usage remains.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/genui/a2ui-playground/lynx-src/a2ui/App.tsx`:
- Line 292: The code is using a double cast (as unknown as
ServerToClientMessage[]) on rawMessages, bypassing TypeScript safety; update
normalizePayloadToMessages to return the correct ServerToClientMessage[] (or
change its return type from ResponseMessages/A2uiMessage[] to
ServerToClientMessage[]) so callers like the assignment to initialMessages can
use a direct, typed value, or implement a small transformer/validator function
that maps/validates A2uiMessage/ResponseMessages to ServerToClientMessage and
use that in place of the double-cast (refer to normalizePayloadToMessages,
rawMessages, initialMessages, A2uiMessage and ServerToClientMessage).
- Around line 56-58: The catalogEntry helper currently accepts component:
unknown and force-casts it to CatalogComponent, bypassing TypeScript checks;
change the function signature catalogEntry(name: string, component: unknown):
CatalogInput to require component: CatalogComponent so the compiler enforces the
shape, then update all call sites that pass components to catalogEntry to
provide properly typed CatalogComponent values (or wrap/convert them to satisfy
CatalogComponent) instead of relying on the runtime cast.
In `@packages/genui/server/agent/a2ui-validator.ts`:
- Around line 246-248: When handling the 'deleteSurface' branch you currently
only remove the surface from the surfaces Map, but you must also clear any
per-surface validation bookkeeping so deleted surfaces don't affect final
root/child/path checks or leave stale data for a re-created surfaceId. In the
deleteSurface branch (where surfaces.delete(msg.deleteSurface.surfaceId) is
called) remove all entries keyed by that surfaceId from whatever per-surface
validation state you maintain (e.g., component-id sets, data-model bookkeeping,
root/child/path maps or indexes used in final checks) so the surface's
accumulated component/data-model state is fully cleaned up.
---
Outside diff comments:
In `@packages/genui/a2ui-playground/lynx-src/a2ui/App.tsx`:
- Around line 25-34: The file App.tsx still imports unused manifest symbols
(buttonManifest, cardManifest, checkBoxManifest, columnManifest,
dividerManifest, imageManifest, listManifest, radioGroupManifest, rowManifest,
textManifest) after migrating to the catalogEntry helper; remove these unused
imports from the top of App.tsx to eliminate dead code and unused-import
warnings and ensure only the active catalogEntry usage remains.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 3bc85a78-5d1d-4f37-8169-0d28385b3ec8
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (22)
.gitignoreeslint.config.jspackages/genui/a2ui-playground/lynx-src/a2ui/App.tsxpackages/genui/a2ui-playground/src/pages/AIChatPage.tsxpackages/genui/a2ui-playground/src/styles.csspackages/genui/server/agent/a2ui-agent.tspackages/genui/server/agent/a2ui-catalog.tspackages/genui/server/agent/a2ui-prompt.tspackages/genui/server/agent/a2ui-validator.tspackages/genui/server/agent/openai-provider.tspackages/genui/server/app/a2ui/action/route.tspackages/genui/server/app/a2ui/chat/route.tspackages/genui/server/app/a2ui/cors.tspackages/genui/server/app/a2ui/health/route.tspackages/genui/server/app/a2ui/reset/route.tspackages/genui/server/app/a2ui/stream/route.tspackages/genui/server/app/layout.tsxpackages/genui/server/next-env.d.tspackages/genui/server/next.config.mjspackages/genui/server/package.jsonpackages/genui/server/service/a2ui-agent.tspackages/genui/server/tsconfig.json
✅ Files skipped from review due to trivial changes (7)
- packages/genui/server/app/layout.tsx
- packages/genui/server/app/a2ui/health/route.ts
- packages/genui/server/next-env.d.ts
- .gitignore
- packages/genui/server/package.json
- packages/genui/a2ui-playground/src/styles.css
- packages/genui/server/tsconfig.json
🚧 Files skipped from review as they are similar to previous changes (13)
- packages/genui/server/app/a2ui/reset/route.ts
- packages/genui/server/agent/a2ui-agent.ts
- packages/genui/server/app/a2ui/cors.ts
- packages/genui/server/agent/a2ui-prompt.ts
- packages/genui/server/app/a2ui/action/route.ts
- eslint.config.js
- packages/genui/server/next.config.mjs
- packages/genui/a2ui-playground/src/pages/AIChatPage.tsx
- packages/genui/server/app/a2ui/stream/route.ts
- packages/genui/server/agent/a2ui-catalog.ts
- packages/genui/server/agent/openai-provider.ts
- packages/genui/server/app/a2ui/chat/route.ts
- packages/genui/server/service/a2ui-agent.ts
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/genui/server/agent/a2ui-validator.ts`:
- Around line 259-266: The loop that checks child references currently only
flags missing IDs from collectChildRefs, but collectChildRefs drops malformed
child shapes (e.g., numeric, boolean, object), allowing silently invalid
payloads; update validation in the same area (the for loop iterating
bucket.values() and using collectChildRefs) to also detect and report malformed
child references by inspecting raw child fields on the component (or extend
collectChildRefs to return invalid entries), and push errors for non-string or
otherwise invalid IDs (e.g., when a child reference is not a string or does not
match expected ID shape) with a message like `Component "${comp.id}" has
malformed child reference ... in surface "${sId}"` so these payloads fail
validation rather than being ignored.
- Around line 169-179: The validation currently only checks
createSurface.catalogId on the first message (using firstMessage/firstIsCreate)
so later messages with createSurface can target a different catalog; move the
catalogId equality check into the main loop that iterates over messages (where
other per-message validations occur) so every message with a createSurface field
verifies createSurface.catalogId === catalog.id, and keep the existing
first-message branch solely for enforcing ordering; also apply the same
relocation for the similar check referenced around the other createSurface
occurrence (the lines noted 190-192).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 92aa3c72-32cd-4b77-97d1-26d484533fad
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (23)
.gitignoreeslint.config.jspackages/genui/a2ui-playground/lynx-src/a2ui/App.tsxpackages/genui/a2ui-playground/src/pages/AIChatPage.tsxpackages/genui/a2ui-playground/src/styles.csspackages/genui/server/agent/a2ui-agent.tspackages/genui/server/agent/a2ui-catalog.tspackages/genui/server/agent/a2ui-prompt.tspackages/genui/server/agent/a2ui-validator.tspackages/genui/server/agent/openai-provider.tspackages/genui/server/app/a2ui/action/route.tspackages/genui/server/app/a2ui/chat/route.tspackages/genui/server/app/a2ui/cors.tspackages/genui/server/app/a2ui/health/route.tspackages/genui/server/app/a2ui/reset/route.tspackages/genui/server/app/a2ui/stream/route.tspackages/genui/server/app/layout.tsxpackages/genui/server/next-env.d.tspackages/genui/server/next.config.mjspackages/genui/server/package.jsonpackages/genui/server/service/a2ui-agent.tspackages/genui/server/tsconfig.jsonpnpm-workspace.yaml
✅ Files skipped from review due to trivial changes (7)
- packages/genui/server/tsconfig.json
- packages/genui/server/package.json
- packages/genui/server/next.config.mjs
- .gitignore
- packages/genui/server/next-env.d.ts
- packages/genui/server/app/layout.tsx
- pnpm-workspace.yaml
🚧 Files skipped from review as they are similar to previous changes (14)
- packages/genui/server/app/a2ui/reset/route.ts
- packages/genui/a2ui-playground/src/styles.css
- packages/genui/server/agent/a2ui-prompt.ts
- packages/genui/server/app/a2ui/health/route.ts
- packages/genui/server/agent/openai-provider.ts
- packages/genui/a2ui-playground/src/pages/AIChatPage.tsx
- packages/genui/server/app/a2ui/chat/route.ts
- packages/genui/a2ui-playground/lynx-src/a2ui/App.tsx
- packages/genui/server/app/a2ui/cors.ts
- packages/genui/server/app/a2ui/stream/route.ts
- eslint.config.js
- packages/genui/server/app/a2ui/action/route.ts
- packages/genui/server/agent/a2ui-catalog.ts
- packages/genui/server/service/a2ui-agent.ts
b03f554 to
a0f5c33
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
♻️ Duplicate comments (1)
eslint.config.js (1)
459-463:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winRemove the likely dead root-level glob from this override.
At Line 462,
'{agent,app,service}/**/*.{ts,tsx}'appears to target non-existent root paths and makes this override harder to reason about. Keep the scoped server pattern only.Proposed fix
{ files: [ 'packages/genui/server/**/*.{ts,tsx}', - '{agent,app,service}/**/*.{ts,tsx}', ], rules: { '@typescript-eslint/no-redundant-type-constituents': 'off', '@typescript-eslint/no-unsafe-argument': 'off', '@typescript-eslint/no-unsafe-assignment': 'off', '@typescript-eslint/no-unsafe-call': 'off', '@typescript-eslint/no-unsafe-member-access': 'off', '@typescript-eslint/no-unsafe-return': 'off', 'n/no-unsupported-features/node-builtins': 'off', }, },🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@eslint.config.js` around lines 459 - 463, The override's files array contains a root-level glob "'{agent,app,service}/**/*.{ts,tsx}'" that likely points to non-existent top-level folders; remove that glob from the files array and keep only the scoped server pattern ('packages/genui/server/**/*.{ts,tsx}') so the override only applies to the intended server code. Locate the override object with the "files" array and delete the "'{agent,app,service}/**/*.{ts,tsx}'" entry.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/genui/a2ui-playground/src/pages/AIChatPage.tsx`:
- Around line 64-89: ONLINE_A2UI_CHAT_URL is empty so getA2UIChatEndpoint falls
back to '' causing fetch('') in production; set ONLINE_A2UI_CHAT_URL to the real
A2UI streaming endpoint URL (the SSE stream that emits incremental
generatedJson) and ensure getA2UIChatEndpoint returns that URL as the default
fallback; verify LOCAL_A2UI_SERVER_PORT and the dev-branch still point to the
local HTTP JSON route only for dev hosts (hostname check and
`http://${window.location.hostname}:${LOCAL_A2UI_SERVER_PORT}/a2ui/chat` remain
unchanged).
In `@packages/genui/server/agent/a2ui-validator.ts`:
- Around line 271-278: The current loop in a2ui-validator.ts incorrectly treats
a provided parent path as covering nested required paths because of the
p.startsWith(provided...) check; remove that branch so coverage is only counted
for exact matches (p === provided) or when a provided path is a descendant of
the required path (i.e., provided.startsWith(p or p + '/')). Update the hasMatch
logic (refer to providedSet, allPaths and the some callback using p.startsWith
and provided.startsWith) to drop the p.startsWith(provided...) clause and only
allow exact equality or provided.startsWith(p.endsWith('/') ? p : p + '/').
In `@packages/genui/server/app/a2ui/health/route.ts`:
- Around line 14-33: The GET health route currently always returns ok: true even
when OPENAI_API_KEY is missing; update the GET function to derive ok from the
required config (e.g., set ok to !!OPENAI_API_KEY or a more complete validation)
so readiness fails when the key is absent, by changing the response object
passed to jsonWithCors inside GET (referencing GET and jsonWithCors and the
OPENAI_API_KEY / hasKey fields).
---
Duplicate comments:
In `@eslint.config.js`:
- Around line 459-463: The override's files array contains a root-level glob
"'{agent,app,service}/**/*.{ts,tsx}'" that likely points to non-existent
top-level folders; remove that glob from the files array and keep only the
scoped server pattern ('packages/genui/server/**/*.{ts,tsx}') so the override
only applies to the intended server code. Locate the override object with the
"files" array and delete the "'{agent,app,service}/**/*.{ts,tsx}'" entry.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 818a5df7-20a8-457e-addf-3db3ef7387d5
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (24)
.gitignoreeslint.config.jspackages/genui/a2ui-playground/lynx-src/a2ui/App.tsxpackages/genui/a2ui-playground/src/pages/AIChatPage.tsxpackages/genui/a2ui-playground/src/styles.csspackages/genui/server/AGENTS.mdpackages/genui/server/agent/a2ui-agent.tspackages/genui/server/agent/a2ui-catalog.tspackages/genui/server/agent/a2ui-prompt.tspackages/genui/server/agent/a2ui-validator.tspackages/genui/server/agent/openai-provider.tspackages/genui/server/app/a2ui/action/route.tspackages/genui/server/app/a2ui/chat/route.tspackages/genui/server/app/a2ui/cors.tspackages/genui/server/app/a2ui/health/route.tspackages/genui/server/app/a2ui/reset/route.tspackages/genui/server/app/a2ui/stream/route.tspackages/genui/server/app/layout.tsxpackages/genui/server/next-env.d.tspackages/genui/server/next.config.mjspackages/genui/server/package.jsonpackages/genui/server/service/a2ui-agent.tspackages/genui/server/tsconfig.jsonpnpm-workspace.yaml
✅ Files skipped from review due to trivial changes (6)
- packages/genui/server/package.json
- packages/genui/server/next.config.mjs
- packages/genui/server/tsconfig.json
- packages/genui/server/AGENTS.md
- pnpm-workspace.yaml
- packages/genui/a2ui-playground/src/styles.css
🚧 Files skipped from review as they are similar to previous changes (14)
- packages/genui/server/app/layout.tsx
- .gitignore
- packages/genui/server/next-env.d.ts
- packages/genui/server/app/a2ui/reset/route.ts
- packages/genui/server/agent/openai-provider.ts
- packages/genui/server/agent/a2ui-prompt.ts
- packages/genui/a2ui-playground/lynx-src/a2ui/App.tsx
- packages/genui/server/agent/a2ui-agent.ts
- packages/genui/server/app/a2ui/action/route.ts
- packages/genui/server/agent/a2ui-catalog.ts
- packages/genui/server/app/a2ui/stream/route.ts
- packages/genui/server/app/a2ui/chat/route.ts
- packages/genui/server/service/a2ui-agent.ts
- packages/genui/server/app/a2ui/cors.ts
412a0df to
c06c42d
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
React External#1397 Bundle Size — 695.33KiB (0%).eb6f819(current) vs 00a0725 main#1386(baseline) Bundle metrics
|
| Current #1397 |
Baseline #1386 |
|
|---|---|---|
0B |
0B |
|
0B |
0B |
|
0% |
0% |
|
0 |
0 |
|
3 |
3 |
|
17 |
17 |
|
5 |
5 |
|
8.59% |
8.59% |
|
0 |
0 |
|
0 |
0 |
Bundle analysis report Branch Sherry-hue:feat/server Project dashboard
Generated by RelativeCI Documentation Report issue
React Example with Element Template#551 Bundle Size — 199.95KiB (0%).eb6f819(current) vs 00a0725 main#540(baseline) Bundle metrics
Bundle size by type
|
| Current #551 |
Baseline #540 |
|
|---|---|---|
145.76KiB |
145.76KiB |
|
54.19KiB |
54.19KiB |
Bundle analysis report Branch Sherry-hue:feat/server Project dashboard
Generated by RelativeCI Documentation Report issue
Web Explorer#9856 Bundle Size — 901.35KiB (0%).eb6f819(current) vs 00a0725 main#9845(baseline) Bundle metrics
Bundle size by type
|
| Current #9856 |
Baseline #9845 |
|
|---|---|---|
497.08KiB |
497.08KiB |
|
402.06KiB |
402.06KiB |
|
2.22KiB |
2.22KiB |
Bundle analysis report Branch Sherry-hue:feat/server Project dashboard
Generated by RelativeCI Documentation Report issue
React Example#8283 Bundle Size — 237.15KiB (0%).eb6f819(current) vs 00a0725 main#8272(baseline) Bundle metrics
|
| Current #8283 |
Baseline #8272 |
|
|---|---|---|
0B |
0B |
|
0B |
0B |
|
0% |
0% |
|
0 |
0 |
|
4 |
4 |
|
197 |
197 |
|
80 |
80 |
|
44.89% |
44.89% |
|
2 |
2 |
|
0 |
0 |
Bundle size by type no changes
| Current #8283 |
Baseline #8272 |
|
|---|---|---|
145.76KiB |
145.76KiB |
|
91.39KiB |
91.39KiB |
Bundle analysis report Branch Sherry-hue:feat/server Project dashboard
Generated by RelativeCI Documentation Report issue
React MTF Example#1416 Bundle Size — 208.1KiB (0%).eb6f819(current) vs 00a0725 main#1405(baseline) Bundle metrics
|
| Current #1416 |
Baseline #1405 |
|
|---|---|---|
0B |
0B |
|
0B |
0B |
|
0% |
0% |
|
0 |
0 |
|
3 |
3 |
|
192 |
192 |
|
77 |
77 |
|
44.4% |
44.4% |
|
2 |
2 |
|
0 |
0 |
Bundle size by type no changes
| Current #1416 |
Baseline #1405 |
|
|---|---|---|
111.23KiB |
111.23KiB |
|
96.86KiB |
96.86KiB |
Bundle analysis report Branch Sherry-hue:feat/server Project dashboard
Generated by RelativeCI Documentation Report issue
7fd85ba to
edf57e5
Compare
Merging this PR will degrade performance by 10.99%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ❌ | transform 1000 view elements |
41.7 ms | 46.9 ms | -10.99% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing Sherry-hue:feat/server (eb6f819) with main (00a0725)
Footnotes
-
26 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
f88ecb6 to
a43c218
Compare
81e86e3 to
499796d
Compare
feat: add server to client
Summary by CodeRabbit
New Features
Improvements
Chores
Checklist