[4471] feat(frontend): Support deploying to multiple environments at once#4572
[4471] feat(frontend): Support deploying to multiple environments at once#4572GanJiaKouN16 wants to merge 2 commits into
Conversation
|
Someone is attempting to deploy a commit to the agenta projects Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (11)
🚧 Files skipped from review as they are similar to previous changes (8)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe PR extends the deploy variant modal to support multi-environment deployment and migrates the trace API layer from deprecated endpoints to canonical paths with updated response schemas. The deploy modal now uses checkboxes instead of radio buttons, loops over selected environments to publish to each, and formats the comma-joined environment list in success messages. Simultaneously, trace API endpoints are migrated from ChangesMulti-environment deployment feature
Trace API endpoint migration and response schema
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (4)
web/oss/src/components/Playground/Components/Modals/DeployVariantModal/index.tsx (1)
67-96:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winMissing dependencies in
useCallbackmay cause stale closure issues.The
deployVariantscallback referencessetModalState,parentVariantId,variantId,revisionId,revision, andmutatebut they're not included in the dependency array. If these props change between renders, the callback will capture stale values when building thenextobject (lines 69-75).Suggested fix
- }, [submitDeploy, onClose, variantName, appId, posthog, recordWidgetEvent]) + }, [ + submitDeploy, + onClose, + variantName, + appId, + posthog, + recordWidgetEvent, + setModalState, + parentVariantId, + variantId, + revisionId, + revision, + mutate, + ])web/packages/agenta-entities/src/trace/api/api.ts (2)
41-49:⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift
fetchAllPreviewTracesnow silently breaks legacy trace-batch consumers.Line 84 drops
focus, Line 97 forcesSpansResponse, and Line 48’s index signature still allows stalefocuscallers to compile. Downstream trace-batch flows that still readdata.traceswill now resolve empty results instead of trace envelopes.Please either (a) migrate those callers in the same PR to the new contract, or (b) keep a compatibility branch here until they are updated.
Based on learnings from provided context snippets:
web/packages/agenta-entities/src/trace/state/prefetch.ts(Lines 104-142) andweb/packages/agenta-entities/src/trace/state/store.ts(Lines 194-236) still passfocus: "trace"and consumedata.traces.Also applies to: 84-97
20-20: 🛠️ Refactor suggestion | 🟠 MajorReplace raw
axiosin trace API with the Fern SDK client
web/packages/agenta-entities/src/trace/api/api.tsstill imports and usesaxiosfor the new trace/span/session endpoints (e.g.,axios.post/get/deletewithURLSearchParamsappended to the URL), instead of using the Fern-generated client (getAgentaSdkClient({host: getAgentaApiUrl()})) and passing query params via{queryParams: {...}}.
fetchAllPreviewTraces:axios.post(~92-95)fetchPreviewTrace:axios.get(~119-121)deletePreviewTrace:axios.delete(~144-146)fetchSessions:axios.post(~204-207)[must migrate these calls to the Fern client; keep
safeParseWithLoggingat the boundary]Source: Coding guidelines
web/oss/src/services/tracing/api/index.ts (1)
19-57: 🛠️ Refactor suggestion | 🟠 Major | 🏗️ Heavy liftRoute these updated tracing API calls through the Fern SDK client.
These migrated endpoints still call
fetchJson/fetchJsonWithMetadirectly. For new frontend API changes, this should go through the shared Fern client singleton and pass query values asqueryParams, with schema validation at the API boundary.As per coding guidelines, “All new frontend API code must go through the Fern-generated client, not raw axios”, “Use
getAgentaSdkClient({host: getAgentaApiUrl()})”, and “Pass query params via{queryParams: {...}}, NOT axios's{params: {...}}.”Also applies to: 91-127, 138-156, 175-205
Source: Coding guidelines
🧹 Nitpick comments (1)
web/packages/agenta-entities/src/trace/api/helpers.ts (1)
36-38: ⚡ Quick winRemove
anyfromisSpansResponsetype guard.Line 37 uses
(data as any).spans, which violates package strict-typing rules and weakens type narrowing.Suggested fix
export const isSpansResponse = (data: unknown): data is SpansResponse => { - return typeof data === "object" && data !== null && "spans" in data && Array.isArray((data as any).spans) + if (typeof data !== "object" || data === null || !("spans" in data)) return false + return Array.isArray((data as {spans?: unknown}).spans) }As per coding guidelines:
web/packages/**/*.{ts,tsx}→ “Do not useanytypes in package code; follow strict typing rules.”Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 91fc681f-14cf-4d47-891d-c09c4a0dbe38
📒 Files selected for processing (11)
web/oss/src/components/Playground/Components/Modals/DeployVariantModal/assets/DeployVariantModalContent/index.tsxweb/oss/src/components/Playground/Components/Modals/DeployVariantModal/index.tsxweb/oss/src/components/Playground/Components/Modals/DeployVariantModal/store/deployVariantModalStore.tsweb/oss/src/services/tracing/api/index.tsweb/packages/agenta-annotation/src/state/controllers/annotationFormController.tsweb/packages/agenta-entities/src/trace/api/api.tsweb/packages/agenta-entities/src/trace/api/helpers.tsweb/packages/agenta-entities/src/trace/api/index.tsweb/packages/agenta-entities/src/trace/core/index.tsweb/packages/agenta-entities/src/trace/core/schema.tsweb/packages/agenta-entities/src/trace/index.ts
| traceResponse?.trace ?? (() => { | ||
| const traceKey = traceId.replace(/-/g, "") | ||
| return (traceResponse as any)?.traces?.[traceKey] ?? | ||
| (traceResponse as any)?.traces?.[traceId] | ||
| })() |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win
Remove any from legacy trace fallback parsing.
The fallback currently uses as any in package code. Please replace it with a narrow legacy response type so this path stays type-safe.
Suggested typed rewrite
+type LegacyTraceResponse = {
+ traces?: Record<string, {spans?: Record<string, TraceSpan> | null} | undefined>
+}
+
const traceEntry =
traceResponse?.trace ?? (() => {
const traceKey = traceId.replace(/-/g, "")
- return (traceResponse as any)?.traces?.[traceKey] ??
- (traceResponse as any)?.traces?.[traceId]
+ const legacy = traceResponse as LegacyTraceResponse | null | undefined
+ return legacy?.traces?.[traceKey] ?? legacy?.traces?.[traceId]
})()As per coding guidelines, “Do not use any types in package code; follow strict typing rules.”
Source: Coding guidelines
Migrate 4 of 5 deprecated /tracing/* endpoints to their canonical
replacements. The analytics endpoint (/tracing/spans/analytics) is
deferred per issue author's recommendation.
Endpoint migrations:
- POST /tracing/spans/query → POST /spans/query
- GET /tracing/traces/{id} → GET /traces/{id}
- DELETE /tracing/traces/{id} → DELETE /traces/{id}
- POST /tracing/sessions/query → POST /spans/sessions/query
Changes:
- Add traceResponseSchema, traceIdResponseSchema, sessionIdsResponseSchema
Zod schemas for the new response shapes
- Update entities API (api.ts) to hit new endpoints with new response
parsing. POST /spans/query now always returns flat SpansResponse
(focus param removed). GET /traces/{id} returns single TraceResponse.
- Update OSS API (index.ts) to hit new URLs, strip focus param
- Update annotationFormController to handle new trace response shape
({trace: {trace_id, spans}} instead of {traces: {id: {spans}}})
- Add isTraceResponse type guard and transformTraceResponseToTree helper
- Existing consumer branching logic (isTracesResponse/isSpansResponse)
continues to work — POST /spans/query always returns SpansResponse
so isTracesResponse branch becomes dead code for list queries
Fixes Agenta-AI#4492
- Change environment selection table from radio (single-select) to checkbox (multi-select) - Deploy to all selected environments in one action - Support partial success: show success for completed envs, warning for failures
|
@CLAassistant please recheck |
704670a to
b4dff88
Compare
Summary
Allow deploying a variant to all selected environments in one action, instead of selecting and deploying one environment at a time.
Changes
Before/After
Before: User selects one environment via radio button → deploys to that single environment.
After: User selects one or more environments via checkboxes → deploys to all selected environments in one action.
Related
Closes #4471