From cdf02d2e538b57f88248894610f3d07819067267 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 26 Aug 2026 12:59:51 +0000 Subject: [PATCH] fix(console): delete dead pre-ADR-0079 getRecordDisplayName/formatRecordTitle copy Both were unimported dead code in apps/console/src/utils.ts, reproducing the pre-ADR-0079 per-surface resolver defect (never reads nameField/ displayNameField, ranks the legacy titleFormat template first). Deleting both (not aliasing) removes the re-armed trap: a same-named, same-signature resolver one import away from console code that already imports resolveKeyedI18nLabel from the same file. Fixes #6558 --- ...8-remove-dead-console-record-title-copy.md | 7 +++ apps/console/src/utils.ts | 52 +++---------------- 2 files changed, 15 insertions(+), 44 deletions(-) create mode 100644 .changeset/6558-remove-dead-console-record-title-copy.md diff --git a/.changeset/6558-remove-dead-console-record-title-copy.md b/.changeset/6558-remove-dead-console-record-title-copy.md new file mode 100644 index 0000000000..ccf03b9b1c --- /dev/null +++ b/.changeset/6558-remove-dead-console-record-title-copy.md @@ -0,0 +1,7 @@ +--- +--- + +Removed a dead pre-ADR-0079 `getRecordDisplayName` / `formatRecordTitle` copy from +`apps/console/src/utils.ts`. Both were unexported-from-behaviour dead code with zero +console importers (superseded by the unified `@object-ui/core#getRecordDisplayName`); +no published behaviour changes. diff --git a/apps/console/src/utils.ts b/apps/console/src/utils.ts index 499860276e..9b32a32087 100644 --- a/apps/console/src/utils.ts +++ b/apps/console/src/utils.ts @@ -34,47 +34,11 @@ export function capitalizeFirst(str: string): string { return str.charAt(0).toUpperCase() + str.slice(1); } -/** - * Format a record title using the titleFormat pattern - * @param titleFormat Pattern like "{name} - {email}", or an Expression - * envelope `{ dialect: 'template', source: '...' }` produced by the - * framework's compile step. - * @param record The record data object - * @returns Formatted title string - */ -export function formatRecordTitle(titleFormat: string | { source?: string } | undefined, record: any): string { - const template: string | undefined = - typeof titleFormat === 'string' - ? titleFormat - : (titleFormat && typeof titleFormat === 'object' && typeof titleFormat.source === 'string') - ? titleFormat.source - : undefined; - - if (!template || !record) { - return record?.id || record?._id || 'Record'; - } - - // Replace {fieldName} patterns with actual values - return template.replace(/\{(\w+)\}/g, (_match, fieldName) => { - const value = record[fieldName]; - if (value === null || value === undefined) { - return ''; - } - return String(value); - }); -} - -/** - * Get display name for a record using titleFormat or fallback - * @param objectDef Object definition with optional titleFormat - * @param record The record data - * @returns Display name for the record - */ -export function getRecordDisplayName(objectDef: any, record: any): string { - if (objectDef?.titleFormat) { - return formatRecordTitle(objectDef.titleFormat, record); - } - - // Fallback: Try common name fields - return record?.name || record?.title || record?.label || record?.id || record?._id || 'Untitled'; -} +// `formatRecordTitle` / `getRecordDisplayName` (a pre-ADR-0079 divergent +// resolver pair, ~6 of which existed across surfaces) were removed here as +// dead code (objectui#6558) — zero console importers, and their presence +// re-armed the exact trap ADR-0079 closed: a same-named, same-signature +// resolver one import away that ignores `nameField`/`displayNameField` and +// ranks the legacy `titleFormat` template first. Console surfaces that need +// a record title use the unified `@object-ui/core#getRecordDisplayName` +// (and `formatTitleTemplate`), which the console already depends on.