Skip to content

feat(studio): redesign Environments page with lineage rail and folded promote drawer#142

Merged
iipanda merged 6 commits into
mainfrom
feat/studio-environments-redesign
May 9, 2026
Merged

feat(studio): redesign Environments page with lineage rail and folded promote drawer#142
iipanda merged 6 commits into
mainfrom
feat/studio-environments-redesign

Conversation

@iipanda
Copy link
Copy Markdown
Collaborator

@iipanda iipanda commented May 9, 2026

Summary

  • Reworks /admin/environments to match the MDCMS design system: definitions-meta strip, lineage rail (root → leaves with extends arrows), and a management table with per-row Promote / Clone / Delete actions.
  • Folds the standalone /admin/promote route into the environments surface as a 3-stage right-anchored drawer (configure → preview/dry-run → run). The /admin/promote nav entry and PromotePage are deleted; the underlying environment-api promote/clone clients are reused.
  • Clone is now a side drawer that mirrors the EnvironmentCloneInput contract (include.content, include.settings, includeDrafts, preservePaths).
  • SPEC-006 updated: the environments route owns clone and promote; the spec describes the lineage / table / drawer surfaces, the configure → preview → run flow, and the requirement that editing inputs after a successful preview must invalidate it before the real run.

Test plan

  • bun test --cwd packages/studio ./src/lib/runtime-ui/app/admin/environments-page.test.tsx ./src/lib/runtime-ui/components/layout/app-sidebar.test.tsx (20 / 20 pass)
  • bun test --cwd packages/studio ./src (589 pass, 1 pre-existing unrelated button.test.tsx failure carried over from main)
  • bunx prettier --check on all touched files
  • Manual: walk Promote drawer through configure → preview → run, confirm dry-run plan + remap counts surface correctly
  • Manual: walk Clone drawer with each toggle combination

Summary by CodeRabbit

  • UI/UX Changes
    • Integrated environment promotion workflow into the environments management interface, replacing the separate promotion page.
    • Removed standalone promotion navigation link; promotion actions are now accessible from the environments management table.
    • Enhanced environments management with lineage visualization, clone, promote, and delete capabilities in a unified interface.

Review Change Stack

… promote drawer

Replace the card-grid environments view with the MDCMS design-system layout:
definitions-meta strip, lineage rail (root → leaves with extends arrows), and a
management table with row-level Promote/Clone/Delete actions. Promote moves
into a 3-stage drawer (configure → preview/dry-run → run) on the same surface,
removing the standalone /admin/promote route. Clone moves into a side drawer
matching the contract toggles. SPEC-006 updated to reflect the new surface.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 9, 2026

Warning

Rate limit exceeded

@iipanda has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 20 minutes before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 83e322c6-4e3b-41e0-9ed5-419bdb3a1d19

📥 Commits

Reviewing files that changed from the base of the PR and between ece6e72 and f63985a.

📒 Files selected for processing (2)
  • packages/studio/src/lib/runtime-ui/app/admin/environments-page.test.tsx
  • packages/studio/src/lib/runtime-ui/app/admin/environments-page.tsx
📝 Walkthrough

Walkthrough

This PR consolidates document promotion from a standalone /admin/promote page route into the /admin/environments management page via drawer-based UI. The specification is updated to establish /admin/environments as the canonical promotion surface with integrated clone/promote workflows. The standalone promote page is removed, and the environments page is restructured with lineage visualization, environment table, and separate promote/clone/delete drawers supporting multi-stage workflows with dry-run preview and deterministic execution tracking.

Changes

Promote Workflow Consolidation

Layer / File(s) Summary
Specification & Route Configuration
docs/specs/SPEC-006-studio-runtime-and-ui.md, packages/studio/src/lib/remote-studio-app.tsx, packages/studio/src/lib/runtime-ui/components/layout/app-sidebar.tsx
Documentation expanded to establish /admin/environments as canonical promotion surface with lineage, clone, and promote workflows; /promote route removed from runtime configuration and sidebar navigation.
Promote Types & Error Handling
packages/studio/src/lib/runtime-ui/app/admin/environments-page.tsx
New exported promote state types (PromoteStage, EnvironmentPromoteSnapshot, EnvironmentPromoteState) and lifecycle definitions added; error-handling utilities refactored to parse runtime messages, status codes, and remap failure details.
UI Building Blocks & Lineage
packages/studio/src/lib/runtime-ui/app/admin/environments-page.tsx
Defaults, constants, and base UI components added: lineage ordering helpers, promote state defaults, PromoteStepper, DefinitionsStrip, LineageCard, and EnvironmentTable structures.
Drawer UI & Environment Management
packages/studio/src/lib/runtime-ui/app/admin/environments-page.tsx
Clone and promote drawer components implemented with full workflows: clone options toggles, promote configure/preview/result stages with document selection, dry-run preview generation, and per-document promotion plan rendering. Environment management page rewritten to integrate drawers alongside table and lineage card.
State Management & Effects
packages/studio/src/lib/runtime-ui/app/admin/environments-page.tsx
EnvironmentsPage extended with promote state, source document loading effects, preview invalidation on input changes, and refactored create/clone/delete handlers with improved error handling and reload behavior.
Promote Handlers & Wiring
packages/studio/src/lib/runtime-ui/app/admin/environments-page.tsx
New promote preview and execute handlers validate session, build snapshots, call environment APIs in dry-run and commit modes, and manage execution state; page view wired with all promote callbacks for dialog/selection/stage management.
Removed Components & Tests
packages/studio/src/lib/runtime-ui/app/admin/promote-page.tsx, packages/studio/src/lib/runtime-ui/app/admin/promote-page.test.tsx
Standalone promote-page component, its exported state/preview types, and all associated test cases deleted as promotion functionality is now fully integrated into the environments page drawer UI.
Test Coverage Updates
packages/studio/src/lib/runtime-ui/app/admin/environments-page.test.tsx
Test suite updated to validate definitions strip rendering, lineage visualization, environment table with per-row actions, promote drawer multi-stage workflow and preview generation, clone drawer options, and delete behavior including production environment constraints.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • mdcms-ai/mdcms#40: Modifies the same environments-page.tsx and EnvironmentManagementPageView UI layout, adjusting card layout and activeEnvironment switching alongside promote/clone workflow integration.
  • mdcms-ai/mdcms#44: Updates the same environments management UI and tests to refactor delete-error handling, reload behavior, and definitionsMeta structure wiring alongside promote/clone functionality.
  • mdcms-ai/mdcms#39: Builds on server-backed environments work by consolidating promote/clone flows into the environments page and removing the separate /promote route.

Poem

🐰 The promote page hops away into a drawer,
Nestled snug within environments, no separate door.
With stages and swaps, a lineage so clear,
Clone and promote dance—oh what harmony here!
From separate to woven, one surface we cheer. 🌱

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: a redesign of the Environments page that adds a lineage rail and incorporates the promote workflow as a folded drawer, matching the primary objectives of the PR.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/studio-environments-redesign

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: 5

🧹 Nitpick comments (1)
packages/studio/src/lib/runtime-ui/app/admin/environments-page.test.tsx (1)

163-229: ⚡ Quick win

Add at least one failing-state test for the new promote flow.

The new assertions stop at the configure happy path. A regression where preview or execute failures stop surfacing in the drawer would still pass, so this flow needs error-path coverage too.

🤖 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/studio/src/lib/runtime-ui/app/admin/environments-page.test.tsx`
around lines 163 - 229, Add a new test in environments-page.test.tsx that
simulates a failing promote flow by extending PROMOTE_DEFAULT_STATE (use
promoteState) to include an error condition (e.g., set a previewError or
executeError message and/or a step like "preview" or "execute" that indicates
failure) and render the page via renderMarkup with promoteTarget and that
promoteState; then assert the drawer still renders and shows the error UI (check
for data attributes like data-mdcms-environment-drawer="promote",
data-mdcms-environment-promote-stepper="preview" or "execute", and an error
indicator such as data-mdcms-environment-promote-error or the specific error
text you injected) so the failing-path is covered alongside the existing
configure happy-path test.
🤖 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/studio/src/lib/runtime-ui/app/admin/environments-page.tsx`:
- Around line 1779-1780: The promote picker currently calls contentApi.list({
limit: 100, sort: "updatedAt", order: "desc" }) which truncates results at 100
and silently drops documents; update the promote picker logic (the call site
using contentApi.list) to fetch exhaustively or support pagination: either
implement a loop that repeatedly calls contentApi.list with the API's pagination
parameters (cursor/offset/nextToken) until no more items are returned, or add UI
pagination/search so users can request additional pages; ensure the code
handling the results (the promote picker component) merges pages and uses the
full result set instead of only the first page.
- Around line 1779-1795: The catch block for contentApi.list currently wipes
documents and hides real fetch failures; instead, add a distinct error flag to
the promote state (e.g., documentsError) and update setPromoteState in the catch
to set documentsLoading: false and documentsError: the caught error (do not
overwrite existing documents unless you explicitly want to clear). Update
PromoteConfigure to accept and render this documentsError state (show a
load-error UI/message) so real GET /content failures are surfaced rather than
falling through to “No documents in source environment.” Ensure you reference
contentApi.list, setPromoteState, and PromoteConfigure when making these
changes.
- Line 629: The header text "sort: createdAt ↑" is incorrect for the shown
ordering; either update the UI label or change the sort logic: find the header
string "sort: createdAt ↑" (and the duplicate at the other occurrence) in the
EnvironmentsPage UI and either (A) change the displayed label to reflect the
actual ordering used (e.g., "sort: default-first · name ↑" or "sort: name ↑"),
or (B) change the data sort used when rendering the environments array to sort
by createdAt ascending so the label is accurate; pick one approach and make the
label and the actual sorting behavior consistent.
- Around line 1981-2007: The preview error path sets preview.status to "error"
but never advances promote state.stage to "preview", so the UI drawer stays in
"configure" and PromotePreview never mounts; update the catch block that calls
setPromoteState (and any related error paths) to also set stage: "preview" when
setting preview: { status: "error", ... } (i.e., modify the setPromoteState in
the catch to include stage: "preview" alongside preview) so failures are
displayed in PromotePreview; refer to setPromoteState, the try/catch around
environmentApi.promote, and the preview state object when making this change.

---

Nitpick comments:
In `@packages/studio/src/lib/runtime-ui/app/admin/environments-page.test.tsx`:
- Around line 163-229: Add a new test in environments-page.test.tsx that
simulates a failing promote flow by extending PROMOTE_DEFAULT_STATE (use
promoteState) to include an error condition (e.g., set a previewError or
executeError message and/or a step like "preview" or "execute" that indicates
failure) and render the page via renderMarkup with promoteTarget and that
promoteState; then assert the drawer still renders and shows the error UI (check
for data attributes like data-mdcms-environment-drawer="promote",
data-mdcms-environment-promote-stepper="preview" or "execute", and an error
indicator such as data-mdcms-environment-promote-error or the specific error
text you injected) so the failing-path is covered alongside the existing
configure happy-path test.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5933301b-e62a-4017-a7e2-2b96369c7e62

📥 Commits

Reviewing files that changed from the base of the PR and between 37ed44e and ece6e72.

📒 Files selected for processing (7)
  • docs/specs/SPEC-006-studio-runtime-and-ui.md
  • packages/studio/src/lib/remote-studio-app.tsx
  • packages/studio/src/lib/runtime-ui/app/admin/environments-page.test.tsx
  • packages/studio/src/lib/runtime-ui/app/admin/environments-page.tsx
  • packages/studio/src/lib/runtime-ui/app/admin/promote-page.test.tsx
  • packages/studio/src/lib/runtime-ui/app/admin/promote-page.tsx
  • packages/studio/src/lib/runtime-ui/components/layout/app-sidebar.tsx
💤 Files with no reviewable changes (4)
  • packages/studio/src/lib/runtime-ui/app/admin/promote-page.test.tsx
  • packages/studio/src/lib/runtime-ui/components/layout/app-sidebar.tsx
  • packages/studio/src/lib/remote-studio-app.tsx
  • packages/studio/src/lib/runtime-ui/app/admin/promote-page.tsx

Comment thread packages/studio/src/lib/runtime-ui/app/admin/environments-page.tsx Outdated
Comment thread packages/studio/src/lib/runtime-ui/app/admin/environments-page.tsx Outdated
Comment thread packages/studio/src/lib/runtime-ui/app/admin/environments-page.tsx Outdated
Comment thread packages/studio/src/lib/runtime-ui/app/admin/environments-page.tsx
Comment thread packages/studio/src/lib/runtime-ui/app/admin/environments-page.tsx
iipanda added 5 commits May 9, 2026 16:58
…s page

EnvironmentSummary.extends holds the parent environment's name, not its id, so
the lineage rail and management table both need a name-keyed lookup to render
the parent chip. The previous id-keyed lookup made the lineage rail fall back
to the raw extends string while the table reported every non-default
environment as "root · no parent". Also drop the redundant entries/sort hint
from the management table card head.
…uthfully

The promote drawer's document picker was capped at the first 100 results from
GET /content with no UI to ask for more, silently dropping any documents past
that page from the promote selection. The fetch error path also wiped the
collected documents and reused the empty-state copy, so a real backend failure
looked identical to "this env is empty". Both regressions are now fixed:

- The picker effect paginates exhaustively against `pagination.hasMore`,
  capped at HARD_CAP=1000 to bound the request count.
- A new `documentsError` field on EnvironmentPromoteState keeps the prior
  document set and routes a deterministic load-failure message into the
  picker, rendered as `data-mdcms-environment-promote-documents-error`.
- The `handlePromotePreview` catch block now advances the stepper to the
  preview stage so PromotePreview mounts and the error surface is visible to
  operators instead of being trapped behind the configure stage.

Adds two new tests covering the failing-flow paths (preview error with remap
details, documents-load error).
… table

Replace API-shaped labels in the promote configure stage and clone drawer with
plain English (Source environment / Target environment / Documents / Include
unpublished / Include content / Include settings / Include drafts / Preserve
paths). Drop the env IDs from the source/target dropdowns so operators see
just the environment name. Remove the redundant "Non-empty array of document
UUIDs in the source env." explainer. In the preview/result plan list, drop
the cryptic v → column (always rendered "—" for dry-run rows), give path the
freed width so it stops truncating, and shrink the status pill so it doesn't
dominate the row.
@iipanda iipanda merged commit 935ec6b into main May 9, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant