feat(studio): redesign Environments page with lineage rail and folded promote drawer#142
Conversation
… 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.
|
Warning Rate limit exceeded
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 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR consolidates document promotion from a standalone ChangesPromote Workflow Consolidation
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 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: 5
🧹 Nitpick comments (1)
packages/studio/src/lib/runtime-ui/app/admin/environments-page.test.tsx (1)
163-229: ⚡ Quick winAdd 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
📒 Files selected for processing (7)
docs/specs/SPEC-006-studio-runtime-and-ui.mdpackages/studio/src/lib/remote-studio-app.tsxpackages/studio/src/lib/runtime-ui/app/admin/environments-page.test.tsxpackages/studio/src/lib/runtime-ui/app/admin/environments-page.tsxpackages/studio/src/lib/runtime-ui/app/admin/promote-page.test.tsxpackages/studio/src/lib/runtime-ui/app/admin/promote-page.tsxpackages/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
…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.
Summary
/admin/environmentsto match the MDCMS design system: definitions-meta strip, lineage rail (root → leaves withextendsarrows), and a management table with per-row Promote / Clone / Delete actions./admin/promoteroute into the environments surface as a 3-stage right-anchored drawer (configure → preview/dry-run → run). The/admin/promotenav entry andPromotePageare deleted; the underlying environment-api promote/clone clients are reused.EnvironmentCloneInputcontract (include.content,include.settings,includeDrafts,preservePaths).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 unrelatedbutton.test.tsxfailure carried over from main)bunx prettier --checkon all touched filesSummary by CodeRabbit