Skip to content

[4471] feat(frontend): Support deploying to multiple environments at once#4572

Open
GanJiaKouN16 wants to merge 2 commits into
Agenta-AI:mainfrom
GanJiaKouN16:feat/multi-env-deploy-4471
Open

[4471] feat(frontend): Support deploying to multiple environments at once#4572
GanJiaKouN16 wants to merge 2 commits into
Agenta-AI:mainfrom
GanJiaKouN16:feat/multi-env-deploy-4471

Conversation

@GanJiaKouN16
Copy link
Copy Markdown

Summary

Allow deploying a variant to all selected environments in one action, instead of selecting and deploying one environment at a time.

Changes

  • Environment selection table: Changed from radio (single-select) to checkbox (multi-select)
  • Deploy submit logic: Iterates over all selected environments and deploys to each one
  • Success message: Lists all deployed environments; shows warning for partial failures
  • UI text: Updated prompt from "Select an environment" to "Select environments"

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

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jun 6, 2026
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 6, 2026

Someone is attempting to deploy a commit to the agenta projects Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Jun 6, 2026

CLA assistant check
All committers have signed the CLA.

@dosubot dosubot Bot added Feature Request New feature or request Frontend labels Jun 6, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 6, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ddfc4a10-3c12-4f5f-acaa-1a81f797df43

📥 Commits

Reviewing files that changed from the base of the PR and between 704670a and b4dff88.

📒 Files selected for processing (11)
  • web/oss/src/components/Playground/Components/Modals/DeployVariantModal/assets/DeployVariantModalContent/index.tsx
  • web/oss/src/components/Playground/Components/Modals/DeployVariantModal/index.tsx
  • web/oss/src/components/Playground/Components/Modals/DeployVariantModal/store/deployVariantModalStore.ts
  • web/oss/src/services/tracing/api/index.ts
  • web/packages/agenta-annotation/src/state/controllers/annotationFormController.ts
  • web/packages/agenta-entities/src/trace/api/api.ts
  • web/packages/agenta-entities/src/trace/api/helpers.ts
  • web/packages/agenta-entities/src/trace/api/index.ts
  • web/packages/agenta-entities/src/trace/core/index.ts
  • web/packages/agenta-entities/src/trace/core/schema.ts
  • web/packages/agenta-entities/src/trace/index.ts
🚧 Files skipped from review as they are similar to previous changes (8)
  • web/oss/src/components/Playground/Components/Modals/DeployVariantModal/assets/DeployVariantModalContent/index.tsx
  • web/packages/agenta-entities/src/trace/api/index.ts
  • web/packages/agenta-entities/src/trace/core/index.ts
  • web/packages/agenta-entities/src/trace/core/schema.ts
  • web/oss/src/services/tracing/api/index.ts
  • web/oss/src/components/Playground/Components/Modals/DeployVariantModal/store/deployVariantModalStore.ts
  • web/packages/agenta-entities/src/trace/api/helpers.ts
  • web/packages/agenta-entities/src/trace/api/api.ts

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Deploy modal: select multiple environments for deployment; success toast lists deployed environments and partial-success warnings shown when applicable.
  • Refactor

    • Trace and session APIs migrated to new canonical endpoints.
    • Trace response parsing and transformation improved to support both new single-trace and legacy multi-trace formats; new trace-related schemas/types exposed.

Walkthrough

The 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 /tracing/* to /spans/* and /traces/*, the focus query parameter is removed, and new response schemas and transformers are introduced to handle the updated API contracts.

Changes

Multi-environment deployment feature

Layer / File(s) Summary
Multi-select environment UI
web/oss/src/components/Playground/Components/Modals/DeployVariantModal/assets/DeployVariantModalContent/index.tsx
Deploy modal header changed to "Select environments" (plural), table row selection switched from radio to checkbox, and row click handler updated to toggle environment name presence in the selected list instead of overwriting with a single-element array.
Multi-environment deployment store logic
web/oss/src/components/Playground/Components/Modals/DeployVariantModal/store/deployVariantModalStore.ts
Deploy variant submit now collects selected environment names, validates non-empty selection, loops over all selected environments to publish to each with shared workflow/revision inputs, aggregates successes and errors, and returns {ok, envs?, error?} supporting partial-success outcomes.
Post-submit environment list handling
web/oss/src/components/Playground/Components/Modals/DeployVariantModal/index.tsx
Success toast and PostHog analytics event now format the result.envs array as a comma-joined string; conditional warning toast displays result.error for partial-success scenarios.

Trace API endpoint migration and response schema

Layer / File(s) Summary
Trace response schemas and types
web/packages/agenta-entities/src/trace/core/schema.ts
Added Zod schemas for three new API responses: TraceResponse (GET /traces/{id} returning single trace with spans), TraceIdResponse (DELETE /traces/{id} returning count and optional trace_id), and SessionIdsResponse (POST /spans/sessions/query returning count, session_ids, and optional windowing pagination).
Trace response helpers and transformers
web/packages/agenta-entities/src/trace/api/helpers.ts
Added isTraceResponse type guard for the new single-trace shape, refined isSpansResponse validation, extracted shared span-tree construction into buildSpanTree helper, and introduced transformTraceResponseToTree to convert new TraceResponse format to the legacy TraceSpanNode[] tree structure.
Core and API module re-exports
web/packages/agenta-entities/src/trace/core/index.ts, web/packages/agenta-entities/src/trace/api/index.ts, web/packages/agenta-entities/src/trace/index.ts
Expanded public exports to include new trace response schemas, types, type guards (isTraceResponse), and transformers (transformTraceResponseToTree).
Entity API module endpoint migration
web/packages/agenta-entities/src/trace/api/api.ts
Updated TraceQueryParams to remove focus parameter; migrated all fetch functions to canonical endpoints: /spans/query for spans and traces queries (removing focus from payload), /traces/{id} for single-trace fetch and deletion, /spans/sessions/query for session queries; updated response validation to use new schemas (SpansResponse, TraceResponse, TraceIdResponse, SessionIdsResponse).
OSS service trace API calls
web/oss/src/services/tracing/api/index.ts
Updated fetchAllPreviewTraces, fetchAllPreviewTracesWithMeta, fetchPreviewTrace, deletePreviewTrace, and fetchSessions to use new endpoint paths and skip the focus parameter from request payloads.
Annotation controller trace response handling
web/packages/agenta-annotation/src/state/controllers/annotationFormController.ts
Updated resolveTraceLinkSpanId to extract spans from new single-trace response shape (traceResponse.trace), with fallback to legacy traces-record map lookup for backward compatibility.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

  • Agenta-AI/agenta#4471: PR directly addresses the objective to support deploying to multiple environments at once, changing from single-environment radio selection to multi-environment checkbox selection.

Possibly related PRs

  • Agenta-AI/agenta#4538: Both PRs modify the deploy-to-environment publish flow in the OSS UI—this PR expands the modal to publish across multiple selected environments, while the retrieved PR fixes environment identifier handling by sending environmentSlug instead of environmentName in publish payloads.
  • Agenta-AI/agenta#4458: Playwright deployment acceptance test adjustments for the "Deploy Development" dialog are likely affected by this PR's change from radio to checkbox and toggling behavior in the environment selection UI.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning Beyond multi-environment deployment support, the PR includes API endpoint path migrations and response schema updates unrelated to issue #4471, which scope-creep the changeset with tracing/span endpoint refactoring. Separate tracing API endpoint migrations and response schema changes into a distinct PR; keep this PR focused solely on multi-environment deployment UI and logic changes.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: enabling deployment to multiple environments simultaneously, which directly aligns with the core functionality added across all modified files.
Description check ✅ Passed The description is well-related to the changeset, providing context about the shift from single-select (radio) to multi-select (checkbox) UI, the deploy logic changes, and messaging updates—all reflected in the code changes.
Linked Issues check ✅ Passed The PR fully implements issue #4471's requirements: multi-select environment control via checkboxes (not radio), iterative deployment to all selected environments, and updated UI messaging reflecting multi-environment selection.
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 60.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 win

Missing dependencies in useCallback may cause stale closure issues.

The deployVariants callback references setModalState, parentVariantId, variantId, revisionId, revision, and mutate but they're not included in the dependency array. If these props change between renders, the callback will capture stale values when building the next object (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

fetchAllPreviewTraces now silently breaks legacy trace-batch consumers.

Line 84 drops focus, Line 97 forces SpansResponse, and Line 48’s index signature still allows stale focus callers to compile. Downstream trace-batch flows that still read data.traces will 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) and web/packages/agenta-entities/src/trace/state/store.ts (Lines 194-236) still pass focus: "trace" and consume data.traces.

Also applies to: 84-97


20-20: 🛠️ Refactor suggestion | 🟠 Major

Replace raw axios in trace API with the Fern SDK client
web/packages/agenta-entities/src/trace/api/api.ts still imports and uses axios for the new trace/span/session endpoints (e.g., axios.post/get/delete with URLSearchParams appended 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 safeParseWithLogging at the boundary]

Source: Coding guidelines

web/oss/src/services/tracing/api/index.ts (1)

19-57: 🛠️ Refactor suggestion | 🟠 Major | 🏗️ Heavy lift

Route these updated tracing API calls through the Fern SDK client.

These migrated endpoints still call fetchJson/fetchJsonWithMeta directly. For new frontend API changes, this should go through the shared Fern client singleton and pass query values as queryParams, 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 win

Remove any from isSpansResponse type 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 use any types 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

📥 Commits

Reviewing files that changed from the base of the PR and between 98b8a9d and 704670a.

📒 Files selected for processing (11)
  • web/oss/src/components/Playground/Components/Modals/DeployVariantModal/assets/DeployVariantModalContent/index.tsx
  • web/oss/src/components/Playground/Components/Modals/DeployVariantModal/index.tsx
  • web/oss/src/components/Playground/Components/Modals/DeployVariantModal/store/deployVariantModalStore.ts
  • web/oss/src/services/tracing/api/index.ts
  • web/packages/agenta-annotation/src/state/controllers/annotationFormController.ts
  • web/packages/agenta-entities/src/trace/api/api.ts
  • web/packages/agenta-entities/src/trace/api/helpers.ts
  • web/packages/agenta-entities/src/trace/api/index.ts
  • web/packages/agenta-entities/src/trace/core/index.ts
  • web/packages/agenta-entities/src/trace/core/schema.ts
  • web/packages/agenta-entities/src/trace/index.ts

Comment on lines +642 to +646
traceResponse?.trace ?? (() => {
const traceKey = traceId.replace(/-/g, "")
return (traceResponse as any)?.traces?.[traceKey] ??
(traceResponse as any)?.traces?.[traceId]
})()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ 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
@GanJiaKouN16
Copy link
Copy Markdown
Author

@CLAassistant please recheck

@GanJiaKouN16 GanJiaKouN16 force-pushed the feat/multi-env-deploy-4471 branch from 704670a to b4dff88 Compare June 6, 2026 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature Request New feature or request Frontend size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support deploying to multiple environments at once

2 participants