Skip to content

fix(settings): reload the cached site document after an import outside the editor - #630

Open
Mineorey wants to merge 1 commit into
CoreBunch:mainfrom
Mineorey:fix/settings-reload-after-import
Open

Mineorey wants to merge 1 commit into
CoreBunch:mainfrom
Mineorey:fix/settings-reload-after-import

Conversation

@Mineorey

Copy link
Copy Markdown

Summary

What. On every admin page except the Site editor, the Settings modal works on a standalone draft store (useSiteSettingsController). That store loaded the site document once and kept it. Now:

  • Any CMS_SITE_RELOAD_EVENT marks the cached document stale: a site import, a plugin install, or a data-workspace write to site tables. This includes an event that arrives while the first load is still in flight. The store's own save announcement does not count.
  • The next render of a Settings section refetches the document once pending saves have settled. If the modal is open, it refetches straight away.
  • A save-generation guard covers loads that started before a save. Such a load throws its response away and fetches again, so it can never overwrite the save or rewind its shell conflict base (shellBaseSeq).
  • The test preload (storeIsolation.ts) now resets the draft store between tests. To allow this, the store is exported.

Why. If you opened Settings before importing a site, it kept showing the pre-import document (name, settings, classes) until a full page reload. Worse, the next settings save was built on top of that outdated copy.

Impact. No change on the Site editor, which reads from the editor store. On other pages, Settings now shows the current site after outside writes. No API, schema or data changes.

Verification

Run in the project's Bun dev container on this branch:

  • bun run build: passes
  • bun test --timeout 60000: 7125 pass, 2 fail. Both failures are environment-related and also fail on main in the same container: the circular-dependency check hits its internal 15 s timeout, and the pixel-art-icons .gitignore freshness check needs git, which the container doesn't have.
  • bun run lint: clean
  • New src/__tests__/settings/siteSettingsReload.test.tsx (5 cases: reload after an import, reload while open, no refetch after its own save, import during the first load, stale load vs. a newer save). 4 of the 5 fail against the old controller.
  • Docker/deployment check: not relevant

Checklist

  • Tests cover behavior changes.
  • Docs were updated (docs/editor.md, Settings data source).
  • No compatibility shim was added for old pre-release behavior.
  • No secrets, local databases, uploads, or generated artifacts are included.

For transparancy: Created with Claude Code

…e the editor

Outside the Site editor the Settings modal caches the site document in a
standalone store and never refetched it, so after a site import, a plugin
install or a data-workspace write to site tables it kept showing (and
saving on top of) the pre-import document until a full page reload.

Any CMS_SITE_RELOAD_EVENT other than the store's own save announcement now
marks the cached copy stale (also while the first load is in flight); the
next render refetches after pending saves have settled, immediately while
the modal is open. A load whose fetch started before a save discards its
response and fetches again, so it cannot roll back that save or rewind its
shell conflict base. The test preload resets the store between tests.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Mineorey
Mineorey marked this pull request as ready for review October 12, 2026 15:50

This branch has not been deployed

No deployments
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