Automatic Environment Backups: config-screen wizard redesign (v0.7.0)#149
Open
roger-datocms wants to merge 5 commits into
Open
Automatic Environment Backups: config-screen wizard redesign (v0.7.0)#149roger-datocms wants to merge 5 commits into
roger-datocms wants to merge 5 commits into
Conversation
Design spec for reworking the Automatic Environment Backups config screen into a gated, per-step wizard with a single source of truth (saved plugin parameters). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Split the ~1.8k-line ConfigScreen monolith into a thin orchestrator plus focused single-purpose units under src/config/: - Pure, unit-tested modules: generateAuthSecret, pluginParams (typed source-of-truth readers), deriveStepStatuses + buildStatusChecklist. - useBackupsConfig hook holding all edit-state, the queued authoritative persister, per-step save+act handlers, and the run-once mount ping. - Accordion chrome (StepSection, StatusBox) and per-step components (StepSecret, StepConnect, StepSchedule, StatusOverview, AdvancedSettings). Behavior changes: - Saved plugin parameters are the single source of truth; the savedFormValues React snapshot is removed. This eliminates the auth-secret desync that made the plugin send the wrong/default token (HTTP 401). - Explicit per-step saves; no global Save button. - Fresh installs auto-generate a 128-bit hex secret; existing secrets are kept. - Preserves the run-once, StrictMode-safe mount health ping, fixing the config-screen infinite request loop. - Persisted-parameter schema is unchanged, so existing installs keep working. Adds 25 unit tests for the pure modules (60 total, all green). tsc + vitest + vite build all pass. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Fixes from the xhigh review of the wizard rewrite: - persistPluginParameters now merges against a running accumulator ref, so sequential mount-flow persists compose even without a CMA token (was clobbering the schedule migration on token-less roles). - Mount health-check success persists only the connection result, not the stale first-render secret/URL snapshot (was reverting a secret saved during the in-flight check). - Mount schedule migration only runs for an actually-stored legacy schedule, so a fresh install no longer auto-completes step 3 with unchosen cadences. - saveAndTestConnection re-creates missing backup environments on connect when a schedule is already saved (restores the old connect behavior for reconnects), surfaces failures via a transient error box independent of persistence, and no longer overwrites a previously-healthy deployment URL on a failed test. - saveSecret clears any recorded connection state on a secret change (not only a healthy one), so re-saving after a 401 doesn't show a stale error. - saveDebug reverts the optimistic toggle and alerts on persist failure. - deriveStepStatuses/buildStatusChecklist drop a dead always-true sub-condition. - StepSection gives a collapsed current/error step an explicit open affordance. - TSDoc added to the remaining internal helpers. tsc + vitest (60) + vite build all green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Step 1 (auth secret): - Regenerate is now an icon button beside the field (tooltip via native title + aria-label); Save and Copy are merged into one "Save and copy" primary button with an inline Spinner while saving. - The edit warning always offers a "Revert to saved?" link (new revertSecret), with the redeploy note shown when a healthy connection exists. - The deploy box no longer repeats the secret value and now reads: set DATOCMS_BACKUPS_SHARED_SECRET to the secret above, then continue with the deployed URL. - New hook handlers: saveAndCopySecret, revertSecret. Accordion / feedback: - Replaced the single expandedStep with a multi-open Set so [Edit] is additive and never collapses a step above the clicked one — fixes the scroll-jump CLS. Kept the custom StepSection (numbered card) over the SDK collapsible Section. - Added SDK Spinners with explicit "what we're waiting for" text to the Connect, Schedule, and Status-overview inline boxes (and per-cadence backup-now rows). New StepTimeline: horizontal progress stepper at the top with done/current/error /upcoming nodes, connectors, and an "All ok!" terminal state. Advanced settings: replaced the opaque "runs in Lambda cron mode only" note with a plain-language explanation of the scheduled-function backup flow (daily 02:05 UTC, clones the primary environment into sandbox backups). tsc + vitest (60) + vite build all green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- README: rewrite Setup for the four-step wizard, refresh "How it works" and "Managing the connection", embed the new config-screen screenshot. - Add a plugin-local AGENTS.md documenting the src/config architecture (params as single source of truth, per-step saves, pure tested modules, the mount run-once/StrictMode and multi-open-accordion gotchas). - CHANGELOG: 0.7.0 entry. - Bump version 0.6.13 → 0.7.0 (minor). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Redesigns the Automatic Environment Backups configuration screen from a flat three-card layout into a guided four-step wizard, and fixes the bugs behind a support ticket (a fresh install failing with
HTTP 401: UNAUTHORIZED - Missing or invalid X-Datocms-Backups-Auth header, plus an infinite request loop on the config screen).Bumps the plugin to v0.7.0. The persisted-parameter schema is unchanged, so existing installs keep working with no migration.
Why
A fresh install was sending the wrong/default auth token. Two root causes:
savedFormValuessnapshot, and the persisted parameter. "Connect" read one while the overview and "Backup now" read another, so the plugin could send a stale/default token → 401.ctx-derived callbacks, andctxchanges identity on everyupdatePluginParameters, so the effect re-fired forever. The screen never settled and the real error was buried several sections down.What changed
Bug fixes
hasRunMountCheckRef/isMountCheckUnmountedRef) with an empty-deps effect.savedFormValuesReact snapshot); every read comes fromctx.plugin.attributes.parametersvia typed getters.Redesign — guided four-step wizard
Architecture
ConfigScreen.tsxinto small, single-purpose units undersrc/config/: pure, unit-tested modules (generateAuthSecret,pluginParams,deriveStepStatuses), theuseBackupsConfigorchestration hook, and per-step components. 60 unit tests (25 new), no new test deps.Docs
AGENTS.md; committed the design spec underdocs/superpowers/specs/; added a CHANGELOG 0.7.0 entry.Screenshot
Testing
tsc --noEmit,vitest run(60 passing), andvite build— all green.Commits
🤖 Generated with Claude Code