Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .changeset/37444-first-screen-studio-catalogue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
'@object-ui/app-shell': patch
'@object-ui/console': patch
'@objectstack/console': patch
---

perf(console): an object list and a record page no longer load the Studio designer's string table on first paint

Clause-②: no
Metadata-protocol: none

Opening an object list or a record page downloaded the Studio designer's English string table (about 69 KB gzipped) and the designer's header and Customize controls with it, before the page could paint, for every user, designer or not. The running app's save paths that load with those pages (a list's view save, the record page's tabs and arrangement saves, the header-pin save) read small pure helpers that lived inside the designer's component modules, and importing a helper loaded the whole module.

Those helpers now live in modules of their own, so each page's first load is about 94 KB gzipped lighter on the Console build this was measured on. Nothing changes in what the pages show or save: every name is still exported from where it was, and the designer loads its string table when it opens, as before.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

import type { ObjectActionLayout } from '@objectstack/spec/data';
import { emitMetadataRefresh } from '../assistant/assistantBus.js';
import { isDraftVersionConflict } from '../views/metadata-admin/DraftConflictDialog.js';
import { isDraftVersionConflict } from '../views/metadata-admin/draftVersionGuard.js';
import { authoredPublished, type AuthoredLayers } from '../views/metadata-admin/authoredObjectBuffer.js';
import { saveObjectExtensionArrangement } from '../views/objectExtensionArrangementSave.js';
import {
Expand Down
4 changes: 2 additions & 2 deletions ui/packages/app-shell/src/layout/designModeMenuSave.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@

import { stripReadDecorations } from '@objectstack/spec/kernel';
import { emitMetadataRefresh } from '../assistant/assistantBus.js';
import { isDraftVersionConflict, publishedPinOf, type DraftPin } from '../views/metadata-admin/DraftConflictDialog.js';
import { overrideDraftBody } from '../views/studio-design/StudioCustomizeControls.js';
import { isDraftVersionConflict, publishedPinOf, type DraftPin } from '../views/metadata-admin/draftVersionGuard.js';
import { overrideDraftBody } from '../views/studio-design/customizeOverride.js';
import {
ensureCustomizationPackage,
fetchListedPackageManifests,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ vi.mock('./studio-design/packages-io', async (importOriginal) => ({
return packages.ensure!(base);
},
}));
vi.mock('./studio-design/StudioCustomizeControls', async (importOriginal) => ({
vi.mock('./studio-design/customizeOverride', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
useCustomizeDoorWalled: () => gate.walled,
}));
Expand Down
2 changes: 1 addition & 1 deletion ui/packages/app-shell/src/views/DashboardView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import {
} from './DashboardInPageEditor.js';
import { StudioReturnButton, useStudioReturnPath } from './StudioReturnButton.js';
import { useInSetupApp } from '../console/setupApp.js';
import { useCustomizeDoorWalled } from './studio-design/StudioCustomizeControls.js';
import { useCustomizeDoorWalled } from './studio-design/customizeOverride.js';
import { readDashboardEditArrival, withoutDashboardEditArrival } from '../layout/designModeArrival.js';

/**
Expand Down
2 changes: 1 addition & 1 deletion ui/packages/app-shell/src/views/RecordTabsConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ import { useObjectTranslation } from '@object-ui/i18n';
import { isRecordPageBuiltinTab, readRelatedListsArrangement, relatedListEntryName } from '@objectstack/spec/data';
import { useDesignMode, useDesignModeActive, useDesignModeChange } from '../layout/designMode.js';
import { useStudioDesignGate, useStudioEntryGate } from '../hooks/useStudioDesignGate.js';
import { useCustomizeDoorWalled } from './studio-design/StudioCustomizeControls.js';
import { useCustomizeDoorWalled } from './studio-design/customizeOverride.js';
import { relatedListEntryNames, type DerivedRelatedList } from '../utils/deriveRelatedLists.js';
import { studioItemPath } from './studio-design/studioAddress.js';
import { entryDetails } from './studio-design/relatedListVocabulary.js';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ vi.mock('./studio-design/packages-io', async (importOriginal) => ({
ensureCustomizationPackage: vi.fn((base: string) => doors.ensure(base)),
}));
const walled = vi.hoisted(() => ({ value: false }));
vi.mock('./studio-design/StudioCustomizeControls', async (importOriginal) => ({
vi.mock('./studio-design/customizeOverride', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
useCustomizeDoorWalled: () => walled.value,
}));
Expand Down
2 changes: 1 addition & 1 deletion ui/packages/app-shell/src/views/ReportView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
saveInPlace,
type InPlaceEditTarget,
} from './runtime-metadata-persistence.js';
import { useCustomizeDoorWalled } from './studio-design/StudioCustomizeControls.js';
import { useCustomizeDoorWalled } from './studio-design/customizeOverride.js';
import { authoredBuffer, extractDraftBody, formatMetadataError, type AuthoredLayers } from '@object-ui/data-objectstack';
import { t as tStudio, tFormat, useMetadataLocale } from './metadata-admin/i18n.js';
import { servedPackageId } from '@object-ui/core';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ vi.mock('../../hooks/useStudioDesignGate', async (importOriginal) => ({
useStudioEntryGate: (path: string | null) => (session.view && path ? { path, posture: 'view' } : null),
}));

vi.mock('../studio-design/StudioCustomizeControls', async (importOriginal) => ({
vi.mock('../studio-design/customizeOverride', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
useCustomizeDoorWalled: () => session.walled,
}));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.

/**
* objectstack#37444 — a list or record page's first load does not carry the
* Studio designer's string table.
*
* The running app's save paths (a list's view save, the record page's tabs and
* arrangement saves, the header-pin save) load with a list or record page. They read pure helpers — the override draft body, the
* object-extension body, the draft-version guard — which used to live in
* component modules (`StudioCustomizeControls.tsx`, `DraftConflictDialog.tsx`)
* that import the designer's `t()` (`metadata-admin/i18n.ts`) and through it
* the `studio` namespace's English catalogue, statically. Measured on the
* Console build of `021524cd`, that put about 94 KB gzipped on both pages'
* first load. The helpers now live in `customizeOverride.ts` and
* `draftVersionGuard.ts`.
*
* This walks each save path's STATIC relative imports in source (type-only
* imports and `import()` excluded, as the browser loads them) and asserts the
* walk never reaches the designer's string table. The walk is checked to see
* the edge it guards: `DraftConflictDialog.tsx` itself must reach it.
*/
import { readFileSync, existsSync } from 'node:fs';
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import { describe, expect, it } from 'vitest';

const SRC = resolve(dirname(fileURLToPath(import.meta.url)), '../..');

/** The designer string table, by file and by package specifier. */
const DESIGNER_I18N_FILE = resolve(SRC, 'views/metadata-admin/i18n.ts');
const DESIGNER_I18N_SPECIFIER = /^@object-ui\/i18n\/namespaces\/studio$/;

/**
* The save paths a list or record page loads with (read off the Console
* build's static closure of `ObjectView` and `RecordDetailView`). The
* design-mode menu save is not one: it loads with design mode, and it still
* reads the app-nav canvas, which translates.
*/
const SAVE_PATHS = [
'views/runtime-metadata-persistence.ts',
'views/recordTabsConfigSave.ts',
'views/objectExtensionArrangementSave.ts',
'layout/designModeHeaderPinsSave.ts',
];

/** Static value imports of one module: `import … from '…'` and `export … from '…'`, never `import type`. */
function staticSpecifiers(code: string): string[] {
const out: string[] = [];
const re = /^\s*(import|export)\s+(?!type\s)([^;]*?\bfrom\s+)?['"]([^'"]+)['"]/gm;
for (const m of code.matchAll(re)) {
if (m[1] === 'export' && !m[2]) continue;
out.push(m[3]);
}
return out;
}

function resolveRelative(from: string, specifier: string): string | null {
const base = resolve(dirname(from), specifier.replace(/\.js$/, ''));
for (const candidate of [`${base}.ts`, `${base}.tsx`, resolve(base, 'index.ts'), resolve(base, 'index.tsx')]) {
if (existsSync(candidate)) return candidate;
}
return null;
}

/** The first chain from `entry` to the designer string table, or `null`. */
function chainToDesignerI18n(entry: string): string[] | null {
const start = resolve(SRC, entry);
const prev = new Map<string, string | null>([[start, null]]);
const queue = [start];
while (queue.length) {
const file = queue.shift() as string;
for (const specifier of staticSpecifiers(readFileSync(file, 'utf8'))) {
if (DESIGNER_I18N_SPECIFIER.test(specifier)) {
const chain = [specifier];
for (let at: string | null = file; at; at = prev.get(at) ?? null) chain.unshift(at.slice(SRC.length + 1));
return chain;
}
if (!specifier.startsWith('.')) continue;
const next = resolveRelative(file, specifier);
if (!next || prev.has(next)) continue;
prev.set(next, file);
if (next === DESIGNER_I18N_FILE) {
const chain: string[] = [];
for (let at: string | null = next; at; at = prev.get(at) ?? null) chain.unshift(at.slice(SRC.length + 1));
return chain;
}
queue.push(next);
}
}
return null;
}

describe('a list or record page first load carries no Studio designer string table (objectstack#37444)', () => {
it('the walk sees the edge it guards: the conflict dialog reaches the designer table', () => {
expect(chainToDesignerI18n('views/metadata-admin/DraftConflictDialog.tsx')).not.toBeNull();
expect(chainToDesignerI18n('views/studio-design/StudioCustomizeControls.tsx')).not.toBeNull();
});

it.each(SAVE_PATHS)('%s reaches no designer string table through static imports', (entry) => {
expect(chainToDesignerI18n(entry)).toBeNull();
});

it('the pure halves import no component module and no string table', () => {
for (const entry of ['views/studio-design/customizeOverride.ts', 'views/metadata-admin/draftVersionGuard.ts']) {
expect(chainToDesignerI18n(entry)).toBeNull();
expect(staticSpecifiers(readFileSync(resolve(SRC, entry), 'utf8'))).not.toContain('@object-ui/components');
}
});
});
Loading
Loading