Skip to content

Commit c9ea363

Browse files
os-billclaude
andauthored
feat(spec,app-shell)!: review follow-ups of #39207 — a navigation keywords list is never empty, and a cleared menu label keeps the entry's keywords (#39356)
<!-- claude-projects-attribution: {"github_login":"os-bill"} --> _Requested by **Bill** · [project thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wg5TiSxMNEj6hh6mizejX4T6)_ Fixes #39210 All four review items of #39207: N1 per the maintainer's ruling (decision card, 2026-12-03 14:48Z: refuse an empty list at both doors), N2, N3 and N4. Clause-②: yes (narrowing) Metadata-protocol: narrowed Skills-docs: none — `skills/**` does not teach navigation `keywords` (grep over `skills/` finds no navigation keywords text) ## Why N1 is a narrowing `@objectstack/spec` 19.0.0-next.4 (the `version packages (next)` cut, 779ff41, on npm since 15:39Z) shipped both keys while this PR was open, and it accepts `keywords: []`. Refusing it now narrows a released shape, so N1 carries its own BREAKING changeset and an ADR-0087 ledger entry. The two consumed notes under `.changeset/pre/` are left as main has them. ## What changes - **N1 (ruled, narrowing).** A navigation `keywords` list is never empty: `.min(1)` with a message that says to leave the key out, on the nav item's `navKeywordsSchema` (`packages/spec/src/ui/app.zod.ts`) and on the translation node's `keywords` (`packages/spec/src/system/translation.zod.ts`). Describes read "at least 1, at most 20". The `@object-ui/types` mirror follows (`ui/packages/types/src/zod/app.zod.ts`). `[]` joins `REFUSED_KEYWORDS` in `app-nav-keywords.test.ts`, which holds both doors to the same verdicts. `content/docs/references/ui/app.mdx` is regenerated. `requiredOneOf` is untouched, and `.min(1)` projects as `minItems`. No writer emits `[]`: the nav editor omits the key, and `mergeNavKeywords` answers `undefined`. - Changeset `.changeset/39210-nav-keywords-never-empty.md` (`@objectstack/spec` minor, `@object-ui/types` patch), BREAKING, with `adr-0087: registered nav-keywords-empty-list-refused`. - Ledger entry `packages/spec/src/migrations/entries/semantic/19.nav-keywords-empty-list-refused.ts`, relevance `stack-declares ['apps', 'translations']`, pinned in `semantic-relevance.test.ts` and `semantic-relevance-coverage-38929.test.ts`. - **N2.** The `translation-contributed-nav-bundle.test.ts` header now describes the current control: a node with neither `label` nor `keywords` is refused at the schema. It used to say a node "still owes its own `label`, at both layers". - **N3.** The new spec changeset names the two other faces that took the 19.0.0-next.4 widening and take this narrowing: `PlatformTranslationData` and `ServedTranslationData` (the body of `GET /i18n/translations/:locale`). - **N4 (defect, user-reachable).** `ui/packages/app-shell/src/layout/designModeMenuSave.ts` `writeMenuTranslation`: clearing an entry's translated label used to delete the whole navigation translation node, and this locale's `keywords` went with it. A cleared label now drops `label` only, and the node stays when it still has keywords. A node left with no keywords is deleted as before. Changeset `.changeset/39210-menu-clear-label-keeps-keywords.md` (`@object-ui/app-shell` patch). ## Tests - New `ui/packages/app-shell/src/layout/__tests__/designModeMenuSave-39210.test.ts`: a node with keywords loses only its label. CONTROLs: a label-only node (deleted), an empty keywords list (deleted), a set label (keywords kept). - ui vitest on designModeMenuSave-39210, designModeMenuSave-36538, designModeMenuSave-36363 and DesignModeMenu-36363: 4 files, 130 tests passed. `@object-ui/types` vitest: 391 files, 10528 tests passed. - `@objectstack/spec` full vitest after N1, before the main merge: 1025 files passed (1 skipped), 30962 tests passed. After the merge: `src/migrations` 6 files, 255 passed. - `check-adr-0087-registration`: 1 declared-breaking changeset, registered, new here. - `@object-ui/app-shell` type-check clean. eslint clean on the touched app-shell files. --- _Generated by [Claude Code](https://claude.ai/code/session_01Utp6CXktGqE1JUHFoagYGj)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent fb4735d commit c9ea363

13 files changed

Lines changed: 218 additions & 62 deletions
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@object-ui/app-shell": patch
3+
---
4+
5+
Clause-②: no
6+
Metadata-protocol: none
7+
8+
Clearing an entry's translated name in the design mode's menu now keeps that entry's translated search keywords in the language's menu translation. Before, the save deleted the entry's whole translation node, so the keywords written for that language went with the name. A node left with no keywords is still deleted (objectstack#39210).
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
'@objectstack/spec': minor
3+
'@object-ui/types': patch
4+
---
5+
6+
feat(spec)!: a navigation `keywords` list is never empty, on the nav item and on the translation node
7+
8+
Clause-②: yes (narrowing)
9+
Metadata-protocol: narrowed
10+
11+
<!-- adr-0087: registered nav-keywords-empty-list-refused -->
12+
13+
**BREAKING** for metadata that writes an empty list: `keywords: []` on a navigation item, or on a translation bundle's navigation node `apps.APP.navigation.ID`, is now refused at every door where 19.0.0-next.4 accepted it. Fix: leave the key out. An empty list never matched a search and never translated anything, and no writer in the platform produces one: the nav editor and the design-mode menu omit the key instead.
14+
15+
Narrowed: each `keywords` array now takes at least 1 and at most 20 words, at the nav item and at the translation node, with a message that says to leave the key out. A translation node carrying only `keywords: []` was accepted as a node that has keywords; it is now refused like a node with neither `label` nor `keywords`.
16+
17+
The same node shape is also part of `PlatformTranslationData` and of `ServedTranslationData`, the body of `GET /i18n/translations/:locale`. Both took the 19.0.0-next.4 widening (a node may carry `keywords` without `label`) and now take this narrowing too.
18+
19+
`@object-ui/types` mirrors the rule on its navigation item schema, so `objectui validate` refuses what the platform's save door refuses.

‎content/docs/references/ui/app.mdx‎

Lines changed: 45 additions & 45 deletions
Large diffs are not rendered by default.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
import type { SemanticMigration } from '../../types.js';
4+
5+
// [#39210] A narrowing of one value, not of a key: an empty `keywords` list on
6+
// a navigation item, or on a translation bundle's navigation node, is refused
7+
// where 19.0.0-next.4 accepted it. The key stays; only `[]` goes. No stored
8+
// row has a meaning to carry over (an empty list matched no search and
9+
// translated nothing), so no D2 conversion: the fix is to drop the key.
10+
export const entry: SemanticMigration = {
11+
id: 'nav-keywords-empty-list-refused',
12+
surface:
13+
'An empty keywords list (keywords: []) on a navigation item in an app\'s navigation, or on a translation '
14+
+ 'bundle\'s navigation node apps.APP.navigation.ID (the file bundle, a registered translation item, the '
15+
+ 'platform translations and the served GET /i18n/translations/:locale body). Each keywords array now takes '
16+
+ 'at least 1 and at most 20 words',
17+
replacement:
18+
'Leave the keywords key out. A translation node whose only key was keywords: [] translates nothing: delete '
19+
+ 'the node, or give it its translated label.',
20+
reason:
21+
'An empty list matched no search and translated nothing, yet a translation node carrying only keywords: [] '
22+
+ 'passed the rule that a node owes a label or keywords. Refusing it keeps that rule true and keeps the nav '
23+
+ 'item and the translation node to one accept set. No writer in the platform produces an empty list.',
24+
acceptanceCriteria:
25+
'AppSchema refuses a navigation item with keywords: [] and TranslationDataSchema refuses '
26+
+ 'apps.APP.navigation.ID with keywords: [], each with a message that says to leave the key out; the same '
27+
+ 'documents without the key, or with one keyword, parse.',
28+
relevantWhen: { kind: 'stack-declares', keys: ['apps', 'translations'] },
29+
};

‎packages/spec/src/migrations/semantic-relevance-coverage-38929.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ const SITES: ReadonlyArray<{ site: string; stack: Record<string, unknown>; entri
370370
entries: ['action-locations-page-parts-retired', 'object-grid-single-click-edit-retired', 'ui-action-type-ask-ai-retired', 'view-bulk-actions-declared-on-the-action', 'cel-list-equality-refused'],
371371
},
372372
{ site: 'dashboards[] (a header action)', stack: { dashboards: [{ name: 'd' }] }, entries: ['ui-action-type-ask-ai-retired', 'publish-refuses-views-and-dashboards-that-save-and-do-not-work'] },
373-
{ site: 'apps[]', stack: { apps: [{ name: 'a' }] }, entries: ['publish-refuses-views-and-dashboards-that-save-and-do-not-work'] },
373+
{ site: 'apps[]', stack: { apps: [{ name: 'a' }] }, entries: ['nav-keywords-empty-list-refused', 'publish-refuses-views-and-dashboards-that-save-and-do-not-work'] },
374374
{
375375
site: 'hooks[]',
376376
stack: { hooks: [{ name: 'h' }] },
@@ -418,7 +418,7 @@ const SITES: ReadonlyArray<{ site: string; stack: Record<string, unknown>; entri
418418
{
419419
site: 'translations[]',
420420
stack: { translations: [{ en: {} }] },
421-
entries: ['translation-form-tails-move-to-forms', 'translation-related-list-key-under-arrangement-refused', 'validation-rule-message-template-holes'],
421+
entries: ['nav-keywords-empty-list-refused', 'translation-form-tails-move-to-forms', 'translation-related-list-key-under-arrangement-refused', 'validation-rule-message-template-holes'],
422422
},
423423
{ site: 'mappings[]', stack: { mappings: [{ name: 'm' }] }, entries: ['incremental-source-delete-policy-stated'] },
424424
{ site: 'books[]', stack: { books: [{ name: 'b' }] }, entries: ['book-audience-two-gates-and-catch-all-claim-refused'] },

‎packages/spec/src/migrations/semantic-relevance.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ const EXPECTED_RELEVANCE: Readonly<Record<string, readonly string[]>> = {
103103
'19:lookup-filter-record-path-structured-refused': ['objects', 'objectExtensions'],
104104
'19:lowered-hook-and-action-bodies-capabilities-judged': ['hooks', 'actions', 'objects'],
105105
'19:master-detail-related-list-tab-by-default': ['objects', 'objectExtensions'],
106+
'19:nav-keywords-empty-list-refused': ['apps', 'translations'],
106107
'19:navigation-mode-record-open-deprecated': ['views', 'viewItems', 'objects'],
107108
'19:object-extension-place-and-cross-package-lists': ['objects', 'objectExtensions'],
108109
'19:object-grid-single-click-edit-retired': ['pages'],

‎packages/spec/src/system/translation-contributed-nav-bundle.test.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
* (this file is compiled by the package's test type-check);
2222
* - `defineStack` (strict) accepts the module stack carrying it;
2323
* - the bare schema parse — the `os validate` door's — accepts it;
24-
* - CONTROL: a navigation entry still owes its own `label`, at both layers;
24+
* - CONTROL: a navigation entry with neither `label` nor `keywords` is refused
25+
* at the schema (the type takes it, since #39146 made `label` optional so a
26+
* node may carry only this locale's `keywords`);
2527
* - CONTROL: an app entry that does author `label` keeps it.
2628
*
2729
* The `os validate` exit-code pin lives in

‎packages/spec/src/system/translation.zod.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,7 +1391,7 @@ const appTranslationDataShape = () => ({
13911391
* half of the nav item's `keywords`, keyed by the same entry id as
13921392
* `label`. The accept set is the nav item's (ui/app.zod.ts
13931393
* `navKeywordsSchema`: each trimmed, non-empty, at most 60 characters,
1394-
* at most 20), restated here because this module does not import the
1394+
* at least 1 and at most 20), restated here because this module does not import the
13951395
* app schema; `app-nav-keywords.test.ts` holds both doors to the same
13961396
* verdicts.
13971397
*
@@ -1413,11 +1413,14 @@ const appTranslationDataShape = () => ({
14131413
+ 'leading or trailing whitespace, no line break. The schema refuses rather than trims it, so what is '
14141414
+ 'stored is what was written.',
14151415
}),
1416-
).max(20, { error: () => 'an entry takes at most 20 keywords — keep the words people actually use for it.' })
1416+
).min(1, {
1417+
error: () => 'a navigation entry\'s `keywords` list is never empty — give at least one word a person would '
1418+
+ 'type to find the entry in this locale, or leave the key out.',
1419+
}).max(20, { error: () => 'an entry takes at most 20 keywords — keep the words people actually use for it.' })
14171420
.optional().describe(
14181421
'Search aliases for this navigation entry in this locale: the words a person '
14191422
+ 'may type to find it, such as its old name after a rename. Each trimmed, non-empty, at most 60 '
1420-
+ 'characters; at most 20. They add to the entry\'s own keywords, never replace them; the command '
1423+
+ 'characters; at least 1, at most 20. They add to the entry\'s own keywords, never replace them; the command '
14211424
+ 'palette matches both.',
14221425
),
14231426
}).refine(requiredOneOf(['label', 'keywords']), {

‎packages/spec/src/ui/app-nav-keywords.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ const BRANCHES: Array<[string, Branch, Record<string, unknown>]> = [
5656
const BASE = { id: 'nav_position_members', label: 'Position Members' };
5757
const KEYWORDS = ['Position Holders', 'Assignments'];
5858

59-
/** Refused at both doors: blank, untrimmed, a line break, over 60 characters, over 20 entries, not strings. */
59+
/** Refused at both doors: an empty list (#39210), blank, untrimmed, a line break, over 60 characters, over 20 entries, not strings. */
6060
const REFUSED_KEYWORDS: unknown[] = [
61-
[''], ['ok', ''], [' '], [' Holders'], ['Holders '], ['Position\nHolders'], ['x'.repeat(61)],
61+
[], [''], ['ok', ''], [' '], [' Holders'], ['Holders '], ['Position\nHolders'], ['x'.repeat(61)],
6262
Array.from({ length: 21 }, (_, i) => `word ${i}`), [42], 'Position Holders',
6363
];
6464
/** Accepted at both doors: an inner space, CJK, and the two bounds exactly. */

‎packages/spec/src/ui/app.zod.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ const NAV_GROUP_ALIASES_GUIDANCE =
193193
/**
194194
* The accept set of one search alias, shared by a nav item's `keywords` and a
195195
* translation bundle node's `keywords` (`system/translation.zod.ts` restates
196-
* the same three numbers and rule; `app-nav-keywords.test.ts` holds the two
196+
* the same numbers and rule; `app-nav-keywords.test.ts` holds the two
197197
* doors to the same verdicts). The rule is the dataset synonym's (ADR-0149 D1),
198198
* the repo's precedent for match-input words: one word or short phrase as a
199199
* person types it, refused rather than trimmed, so what is stored is what was
@@ -205,14 +205,17 @@ const NAV_KEYWORD_NOT_TRIMMED =
205205
'a navigation keyword is one word or phrase as a person types it in search: not empty, no leading or '
206206
+ 'trailing whitespace, no line break. The schema refuses rather than trims it, so what is stored is '
207207
+ 'what was written.';
208+
const NAV_KEYWORDS_EMPTY =
209+
'a navigation entry\'s `keywords` list is never empty — give at least one word a person would type to '
210+
+ 'find the entry, or leave the key out.';
208211
const navKeywordsSchema = () => z.array(
209212
z.string()
210213
.max(NAV_KEYWORD_MAX_LENGTH, {
211214
error: () => `a navigation keyword is at most ${NAV_KEYWORD_MAX_LENGTH} characters — one word or short `
212215
+ 'phrase a person would type to find the entry.',
213216
})
214217
.regex(/^\S(?:.*\S)?$/u, { error: () => NAV_KEYWORD_NOT_TRIMMED }),
215-
).max(NAV_KEYWORDS_MAX, {
218+
).min(1, { error: () => NAV_KEYWORDS_EMPTY }).max(NAV_KEYWORDS_MAX, {
216219
error: () => `an entry takes at most ${NAV_KEYWORDS_MAX} keywords — keep the words people actually use for it.`,
217220
});
218221

@@ -434,7 +437,7 @@ const BaseNavItemSchema = z.object({
434437
+ 'name after a rename. Source-language strings as authored; another locale\'s aliases come from the '
435438
+ "translation bundle entry `apps.<app>.navigation.<id>.keywords`, keyed by this entry's `id`. Search only: "
436439
+ 'never shown as the entry\'s text, never a route, never a gate. Each trimmed, non-empty, at most 60 '
437-
+ 'characters; at most 20. The command palette reads it on the eight leaf kinds, object, dashboard, '
440+
+ 'characters; at least 1, at most 20. The command palette reads it on the eight leaf kinds, object, dashboard, '
438441
+ 'page, report, component, url, doc and action entries (an action hit is drawn apart and runs the action), '
439442
+ 'and on a group, whose keywords find the entries under it.',
440443
),

0 commit comments

Comments
 (0)