Files
EpicNext-Cms/src/components/admin/studio
openhands 9cc57cddfc feat(catalog): update the catalog live after an import, no page refresh
Organising imports, the Studio furni batch, the catalog totals and the
"import from a source" stats all used to need a full page reload, or at
best a router.refresh() that re-rendered the whole admin route, before
anything on screen reflected what the import had just written.

- live-catalog-merge.ts (new): pure tree and total arithmetic. Applies a
  delta of created pages, added offers and moved offers, recomputes depth
  for the touched subtree, bumps parent child counts and the item totals.
  Returns the input untouched when a delta is empty, so subscribers can
  bail out instead of re-rendering. Depth resolution tolerates a parent
  cycle in a dirty DB and still terminates, matching getTreeFlat.
- use-live-catalog.ts (new): one module-level store exposed through
  useSyncExternalStore, so every consumer shares a single instance without
  threading a provider through the admin layout. Deltas only apply to the
  "normal" catalog, so public and public_handlers trees stay separate.
  seedCatalogTotals() takes the first server value per mode and never
  overwrites it afterwards, so a later hard render cannot make the header
  totals jump backwards.
- actions/catalog.ts: organizeImportFurni now reports each group through
  the new OrganizedPageChange, carrying parentId, pageLayout, the icon,
  isNew and the per-source movedFrom counts, so the client can fold the
  result into the tree without reading the page back.
- organize-imports-dialog.tsx: drops useRouter and router.refresh(); the
  response is applied as a delta the moment the run finishes.
- studio-client.tsx: reads the tree from the store instead of freezing it
  with useState(initialTree), loads it on mount when empty, and refreshes
  it once a batch import settles. The batch is server-side and derives its
  import pages from furnidata, so that one path re-reads the tree via
  GET /api/admin/catalog/tree?mode=full rather than trusting the delta.
- studio/furni/page.tsx: stops calling getTreeFlat() and no longer passes
  initialTree; the store is the single source of truth for the rail.
- import-clone-client.tsx: tracks which items are already present, so
  present and clonable update per cloned row instead of only at the end.
- catalog-manager-dialog.tsx: seeds the totals once and renders the live
  values, so the header reflects an import that just ran.
- e2e/ui/fixtures/entry.tsx: drops the removed initialTree prop.
2026-09-29 15:34:36 +02:00
..

Catalog Studio code map

studio-client.tsx composes the workspace, selection and actions. Keep reusable data handling outside its render tree.

Client responsibilities

  • studio-filters.ts: pure filtering and sorting of the loaded furniture list; never mutates the input array.
  • use-studio-translations.ts: language selection, persisted defaults and translation requests.
  • use-furniture-jobs.ts: queue submission, retry identity, polling and completion notifications.
  • furniture-jobs.tsx: job history and retry controls.
  • use-furniture-inspection.ts: cancellable inspection requests and explicit rechecks.
  • furniture-inspector.tsx: local component status, source comparison and repair controls.
  • import-review.tsx: import review, actionable review groups and attachment confirmation.
  • import-recommendation.ts: completion, conflict and verification recommendations from inspected component evidence.
  • studio-types.ts: shared client data types.

Server responsibilities

  • src/lib/services/furniture-inspection.ts: reads SQL, catalog offers, furnidata and asset presence.
  • src/lib/furni/studio-inspection.ts: shared validation, comparison and completeness classification.
  • src/lib/services/furniture-repair.ts: preflight, preservation options and post-repair verification.
  • src/lib/services/furni-job-worker.ts: durable queued work and per-item results.

Keep client modules free of filesystem/database imports. Background refreshes must not reset open editors or unsaved input. Completion status must come from verification, not optimistic UI flags.

Detail navigation keeps the mounted workspace state and restores the list scroll position and originating control on close. Escape closes an open detail before clearing selection. Furniture responses must belong to the latest list request; source changes invalidate pending detail, review and delete state. Selection is never persisted outside the mounted workspace.